com.ibm.websphere.samples.activitysessionWAR
Class MasterMind

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.ibm.websphere.samples.activitysessionWAR.MasterMind
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class MasterMind
extends javax.servlet.http.HttpServlet

The MasterMind Servlet.
At the start of a game the Servlet creates a new HttPSession and stores a reference to an instance of the MasterMindGame Entity EJB. The servlet solicits guesses from the user and displays the results. Once the game is over, either because the guess is corrrect, too many guesses have been attempted, or a new game has been requested, the session is invalidated and the EJB removed.
Since the Servlet is deployed with an activity session control of webcontainer, an ActivitySession is associated with the HttpSession. This ties in with the activation policy of the EJB, which is ActivitySession, and hence the EJB remains in active state for the duration of the HttpSession, or until it is deleted.

See Also:
Serialized Form

Constructor Summary
MasterMind()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process incoming HTTP GET requests by passing them to performTask
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process incoming HTTP POST requests by passing them to performTask
 java.lang.String getServletInfo()
          Returns the servlet info string.
 void init()
          Initializes the servlet.
 void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process incoming requests for information The method examines the action in the form and either processes a new game, a guess, or a request for Instructions.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MasterMind

public MasterMind()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Process incoming HTTP GET requests by passing them to performTask

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - Object that encapsulates the request to the servlet
response - Object that encapsulates the response from the servlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Process incoming HTTP POST requests by passing them to performTask

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - Object that encapsulates the request to the servlet
response - Object that encapsulates the response from the servlet
Throws:
javax.servlet.ServletException
java.io.IOException

getServletInfo

public java.lang.String getServletInfo()
Returns the servlet info string.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
String

init

public void init()
Initializes the servlet.

Overrides:
init in class javax.servlet.GenericServlet

performTask

public void performTask(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response)
Process incoming requests for information The method examines the action in the form and either processes a new game, a guess, or a request for Instructions.

Parameters:
request - Object that encapsulates the request to the servlet
response - Object that encapsulates the response from the servlet