How to send an email from UNIX using mailx.


#!/bin/sh
#
# Purpose: Demonstrate how to send an email from UNIX using mailx.
############################################################

# Example 1 – Simple:
echo “This is the body.”| mailx -s “mailx Test1” sample@sample.com

# Example 2 – Using Variables:
SUBJECT=”mailx Test2″
EMAIL_ADDRESS=”sample@sample.com
BODY=”This is the body of the message.”

echo “$BODY” | mailx -s “$SUBJECT” “$EMAIL_ADDRESS”

Continue reading “How to send an email from UNIX using mailx.”

DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704

SQLCODE -204 is "object does not exist".

I was getting this error while executing a query, this was happening because I was using the SCHEMA name of Q7 database and executing the query inside Q0 db.

means not able to find table with given user id.

When I corrected the db name it works fine.

This error also appear when you are not using schema name in query.

When we need HttpSessionBindingListener?

The HttpSessionBindingListener interface is implemented when an object needs to be notified if it's being bound to a session or unbound from a session.

Objects implement this interface so that they can be notified when they are being bound or unbound from a HttpSession. When a binding occurs (using HttpSession.setAttribute()) HttpSessionBindingEvent communicates the event and identifies the session into which the object is bound. Similarly, when an unbinding occurs (using HttpSession.removeAttribute()) HttpSessionBindingEvent communicates the event and identifies the session from which the object is unbound.

This interface has two methods, that are notified when the status of the object has changed:

  • public void valueBound(HttpSessionBindingEvent event) : Notifies the object that it is being bound to a session and identifies the session.
  • public void valueUnbound(HttpSessionBindingEvent event) : Notifies the object that it is being unbound from a session and identifies the session.

Note, this listener will not be declared in the deployment descriptor as the same as HttpSessionActivationListener interface. The container at runtime will introspect this object to see if it implements the HttpSessionActivationListener and/or HttpSessionBindingListener and fires appropriate events to the object.

These methods have a HttpSessionBindingEvent parameter that can be used to retrieve the session that the object was bound to and the name it was given in the session.

Class HttpSessionBindingEvent

Events of this type are either sent to an object that implements HttpSessionBindingListener when it is bound or unbound from a session, or to a HttpSessionAttributeListener that has been configured in the deployment descriptor when any attribute is bound, unbound or replaced in a session.

The session binds the object by a call to HttpSession.setAttribute and unbinds the object by a call to HttpSession.removeAttribute.

The methods of this object that are used to get the name that's assigned to the object, the session it's bound to, and the actual object:

  • public String getName() : Returns the name with which the attribute is bound to or unbound from the session.
  • public Object getValue() : Returns the value of the attribute that has been added, removed or replaced. If the attribute was added (or bound), this is the value of the attribute. If the attrubute was removed (or unbound), this is the value of the removed attribute. If the attribute was replaced, this is the old value of the attribute.
  • public HttpSession getSession() : Return the HttpSession that the object was bound to or unbound from.