com.ibm.as400.util.servlet
Class AS400Servlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.ibm.as400.util.servlet.AuthenticationServlet
              extended by com.ibm.as400.util.servlet.AS400Servlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class AS400Servlet
extends AuthenticationServlet

The AS400Servlet class is an abstract class that represents an HTML Servlet.

A connection pool can be used to share connections and manage the number of connections a servlet user can have to the system. When using connection pooling and a system is requested, a fully functional AS400 object is returned to the calling application. It is then up to the application to return the AS400 object to the pool. It is not recommended that an application use this object to create additional connections as the pool would not keep track of these connections.

See Also:
Serialized Form

Constructor Summary
AS400Servlet()
          Constructs a default AS400Servlet object.
AS400Servlet(boolean useConnectionPool)
          Constructs an AS400Servlet object specifing whether to use the connection pool.
 
Method Summary
 void destroy()
          Close the connection pool.
 AS400ConnectionPool getConnectionPool()
          Returns the connection pool.
 String getDocumentEnd()
          Returns the tag containing the servlet ending.
 String getDocumentHead()
          Returns the tag containing the servlet head.
 AS400 getSystem()
          Returns an object representing the system.
 AS400 getSystem(int service)
          Returns an object representing the system.
 AS400 getSystem(String systemName)
          Returns an object representing the system.
 AS400 getSystem(String systemName, int service)
          Returns an object representing the system.
 AS400 getSystem(String systemName, String userId, String password)
          Returns an object representing the system.
 AS400 getSystem(String systemName, String userId, String password, int service)
          Returns an object representing the system.
 boolean isUseConnectionPool()
          Indicates if the connection pool is being used.
 void returnSystem(AS400 system)
          Return the system object to the pool when connection pooling is being used.
 void setDocumentEnd(String end)
          Set the html document end tags.
 void setDocumentHead(String head)
          Sets the html document starting tags.
 void setUseConnectionPool(boolean useConnectionPool)
          Sets the AS400Servlet to use the connection pool.
 boolean validateAuthority(String realm, String uid, String pw)
          Method used to validate authority.
 
Methods inherited from class com.ibm.as400.util.servlet.AuthenticationServlet
bypassAuthentication, getLog, getRealm, getUser, init, log, log, postValidation, service, setLog, setPassword, setRealm, setUser
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AS400Servlet

public AS400Servlet()
Constructs a default AS400Servlet object.


AS400Servlet

public AS400Servlet(boolean useConnectionPool)
Constructs an AS400Servlet object specifing whether to use the connection pool. The default is false.

Parameters:
useConnectionPool - true if using connection pool; false otherwise.
Method Detail

destroy

public void destroy()
Close the connection pool.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getConnectionPool

public AS400ConnectionPool getConnectionPool()
Returns the connection pool. The returned pool object allows the connection pool properties to be changed.

Returns:
The connection pool.

getDocumentEnd

public String getDocumentEnd()
Returns the tag containing the servlet ending.

Returns:
The tag.

getDocumentHead

public String getDocumentHead()
Returns the tag containing the servlet head.

Returns:
The tag.

getSystem

public AS400 getSystem()
                throws ConnectionPoolException
Returns an object representing the system.

Returns:
The system object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(String systemName)
                throws ConnectionPoolException
Returns an object representing the system. It uses the specified systemName.

Parameters:
systemName - The name of the system.
Returns:
The system object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(int service)
                throws AS400SecurityException,
                       IOException,
                       ConnectionPoolException
Returns an object representing the system. It connects to the specified service.

Parameters:
service - The name of the service.
Returns:
The system object.
Throws:
AS400SecurityException - If a security or authority error occurs.
IOException - If an error occurs while communicating with the system.
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(String systemName,
                       int service)
                throws AS400SecurityException,
                       IOException,
                       ConnectionPoolException
Returns an object representing the system. It connects to the specified systemName and service.

Parameters:
systemName - The name of the system.
service - The name of the service.
Returns:
The system object.
Throws:
AS400SecurityException - If a security or authority error occurs.
IOException - If an error occurs while communicating with the system.
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(String systemName,
                       String userId,
                       String password)
                throws ConnectionPoolException
Returns an object representing the system. It uses the specified systemName, user ID, and password.

Parameters:
systemName - The name of the system.
userId - The user ID to use to connect to the system.
password - The password to use to connect to the system.
Returns:
The system object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(String systemName,
                       String userId,
                       String password,
                       int service)
                throws AS400SecurityException,
                       IOException,
                       ConnectionPoolException
Returns an object representing the system. It uses the specified systemName, user ID, password, and service.

Parameters:
systemName - The name of the system.
userId - The user ID to use to connect to the system.
password - The password to use to connect to the system.
service - The name of the service.
Returns:
The system object.
Throws:
AS400SecurityException - If a security or authority error occurs.
IOException - If an error occurs while communicating with the system.
ConnectionPoolException - If a connection pool error occurs.

isUseConnectionPool

public boolean isUseConnectionPool()
Indicates if the connection pool is being used. The default value is false.

Returns:
true if using connection pool; false otherwise.

setDocumentEnd

public void setDocumentEnd(String end)
Set the html document end tags.

Parameters:
end - The end tags.

setDocumentHead

public void setDocumentHead(String head)
Sets the html document starting tags.

Parameters:
head - The starting tags.

setUseConnectionPool

public void setUseConnectionPool(boolean useConnectionPool)
Sets the AS400Servlet to use the connection pool. The default is false.

Parameters:
useConnectionPool - true if using connection pool; false otherwise.
See Also:
AS400ConnectionPool

returnSystem

public void returnSystem(AS400 system)
Return the system object to the pool when connection pooling is being used.

Parameters:
system - The system object.

validateAuthority

public final boolean validateAuthority(String realm,
                                       String uid,
                                       String pw)
                                throws SecurityException,
                                       IOException
Method used to validate authority.

Overrides:
validateAuthority in class AuthenticationServlet
Parameters:
realm - The realm to validate against.
uid - The user ID to use for validation.
pw - The password to use for validation.
Returns:
always true.
Throws:
SecurityException - This exception should be thrown if validation fails.
IOException - This exception should be thrown if a communication error occurs during validation.