example.session.counter
Class CounterServlet
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--example.session.counter.CounterServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class CounterServlet
- extends javax.servlet.http.HttpServlet
Client servlet querying a server about a greeting.
JNDI client configuration
<jndi-link>
<jndi-name>java:comp/env/ejb</jndi-name>
<jndi-factory>com.caucho.ejb.BurlapContextFactory</jndi-factory>
<init-param java.naming.provider.url="http://localhost:8080/cmp/example"/>
</jndi-link>
- See Also:
- Serialized Form
Fields inherited from class javax.servlet.GenericServlet |
config |
Method Summary |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Calls the counter twice. |
void |
init()
The init method looks up the CounterHome interface using JNDI and
stores it in a servlet variable. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPost, doPut, doTrace, encodeBase64, generateETag, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
counterHome
private CounterHome counterHome
- The servlet stores the home interface after the initial lookup.
Since the home interface never changes, caching the lookup will save
some performance.
CounterServlet
public CounterServlet()
init
public void init()
throws javax.servlet.ServletException
- The init method looks up the CounterHome interface using JNDI and
stores it in a servlet variable.
- Overrides:
init
in class javax.servlet.GenericServlet
doGet
public void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.io.IOException,
javax.servlet.ServletException
- Calls the counter twice. Since it's a stateful session bean, the
counter is new for each call.
- Overrides:
doGet
in class javax.servlet.http.HttpServlet
- Parameters:
request
- the servlet request object.response
- the servlet response object.