example.cmp.single_table
Class HouseServlet

example.cmp.single_table.HouseServlet

public class HouseServlet

Example database client servlet using the house table. Typically, Resin-CMP clients will be servlets, their associated classes and JSPs.

JNDI client configuration

 <jndi-link>
   <jndi-name>java:comp/env/cmp</jndi-name>
   <jndi-factory>com.caucho.ejb.LocalContextFactory</jndi-factory>
   <init-param java.naming.provider.url="http://localhost:8080/cmp/example"/>
 </jndi-link>
 


Field Summary
private  HouseHome houseHome
          The servlet stores the home interface after the initial lookup.
 
Constructor Summary
HouseServlet()
           
 
Method Summary
 void doGet(example.cmp.single_table.HttpServletRequest request, example.cmp.single_table.HttpServletResponse response)
          Returns the points for the named houses.
 void init()
          The init method looks up the HouseHome interface using JNDI and stores it in a servlet variable.
 

Field Detail

houseHome

private HouseHome houseHome
The servlet stores the home interface after the initial lookup. Since the home interface never changes, caching the lookup will save some performance.
Constructor Detail

HouseServlet

public HouseServlet()
Method Detail

init

public void init()
          throws example.cmp.single_table.ServletException
The init method looks up the HouseHome interface using JNDI and stores it in a servlet variable.

doGet

public void doGet(example.cmp.single_table.HttpServletRequest request,
                  example.cmp.single_table.HttpServletResponse response)
           throws java.io.IOException,
                  example.cmp.single_table.ServletException
Returns the points for the named houses. The House interface is found using the findByPrimaryKey method.

A more complicated example would define a findAll method to return all the current houses rather than hard-coding them in the servlet.

Parameters:
request - the servlet request object.
response - the servlet response object.