com.ibm.as400.util.servlet
Class AS400Servlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.ibm.as400.util.servlet.AuthenticationServlet
                    |
                    +--com.ibm.as400.util.servlet.AS400Servlet
All Implemented Interfaces:
java.io.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 AS/400. 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.
 java.lang.String getDocumentEnd()
          Returns the tag containing the servlet ending.
 java.lang.String getDocumentHead()
          Returns the tag containing the servlet head.
 AS400 getSystem()
          Returns an AS400 object.
 AS400 getSystem(int service)
          Returns an AS400 object.
 AS400 getSystem(java.lang.String systemName)
          Returns an AS400 object.
 AS400 getSystem(java.lang.String system, int service)
          Returns an AS400 object.
 AS400 getSystem(java.lang.String systemName, java.lang.String userId, java.lang.String password)
          Constructs an AS400 object.
 AS400 getSystem(java.lang.String systemName, java.lang.String userId, java.lang.String password, int service)
          Constructs an AS400 object.
 boolean isUseConnectionPool()
          Indicates if the connection pool is being used.
 void returnSystem(AS400 system)
          Return the AS400 object to the pool when connection pooling is being used.
 void setDocumentEnd(java.lang.String end)
          Set the html document end tags.
 void setDocumentHead(java.lang.String head)
          Sets the html document starting tags.
 void setUseConnectionPool(boolean useConnectionPool)
          Sets the AS400Servlet to use the connection pool.
 boolean validateAuthority(java.lang.String realm, java.lang.String uid, java.lang.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.
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 java.lang.String getDocumentEnd()
Returns the tag containing the servlet ending.
Returns:
The tag.

getDocumentHead

public java.lang.String getDocumentHead()
Returns the tag containing the servlet head.
Returns:
The tag.

getSystem

public AS400 getSystem()
                throws ConnectionPoolException
Returns an AS400 object.
Returns:
The AS400 system object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(java.lang.String systemName)
                throws ConnectionPoolException
Returns an AS400 object. It uses the specified system.
Parameters:
systemName - The name of the AS/400.
Returns:
The AS400 systen object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(int service)
                throws AS400SecurityException,
                       java.io.IOException,
                       ConnectionPoolException
Returns an AS400 object. It connects to the specified service.
Parameters:
service - The name of the AS/400 service.
Returns:
The AS400 systen object.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(java.lang.String system,
                       int service)
                throws AS400SecurityException,
                       java.io.IOException,
                       ConnectionPoolException
Returns an AS400 object. It connects to the specified system and service.
Parameters:
system - The name of the AS400.
service - The name of the AS/400 service.
Returns:
The AS400 systen object.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(java.lang.String systemName,
                       java.lang.String userId,
                       java.lang.String password)
                throws ConnectionPoolException
Constructs an AS400 object. It uses the specified system, user ID, and password.
Parameters:
systemName - The name of the AS/400.
userId - The user ID to use to connect to the system.
password - The password to use to connect to the system.
Returns:
The AS400 systen object.
Throws:
ConnectionPoolException - If a connection pool error occurs.

getSystem

public AS400 getSystem(java.lang.String systemName,
                       java.lang.String userId,
                       java.lang.String password,
                       int service)
                throws AS400SecurityException,
                       java.io.IOException,
                       ConnectionPoolException
Constructs an AS400 object. It uses the specified system, user ID, password, and service.
Parameters:
systemName - The name of the AS/400.
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 AS/400 service.
Returns:
The AS400 systen object.
Throws:
AS400SecurityException - If a security or authority error occurs.
java.io.IOException - If an error occurs while communicating with the AS/400.
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(java.lang.String end)
Set the html document end tags.
Parameters:
html - The end tags.

setDocumentHead

public void setDocumentHead(java.lang.String head)
Sets the html document starting tags.
Parameters:
html - 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 AS400 object to the pool when connection pooling is being used.
Parameters:
system - The AS400 system object.

validateAuthority

public final boolean validateAuthority(java.lang.String realm,
                                       java.lang.String uid,
                                       java.lang.String pw)
                                throws java.lang.SecurityException,
                                       java.io.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:
java.lang.SecurityException - This exception should be thrown if validation fails.
java.io.IOException - This exception should be thrown if a communication error occurs during validation.