Methods Summary |
---|
public void | destroy()Destroys the servlet.
|
protected void | doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handles the HTTP GET method.
processRequest(request, response);
|
protected void | doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handles the HTTP POST method.
processRequest(request, response);
|
protected java.lang.String | formatMovieInfo()
StringBuffer result = new StringBuffer();
Extent movies = pm.getExtent(Movie.class, true);
Iterator it = movies.iterator();
while (it.hasNext()) {
result.append("<P>");
Movie movie = (Movie)it.next();
result.append(movie.getDescription());
}
return result.toString();
|
public java.lang.String | getServletInfo()Returns a short description of the servlet.
return "Movie Information";
|
public void | init()
try {
ServletContext ctx = getServletContext();
InputStream in = ctx.getResourceAsStream("WEB-INF/pmf.properties");
Properties props = new Properties();
props.load(in);
persistenceManagerFactory =
JDOHelper.getPersistenceManagerFactory(props);
} catch (IOException ex) {
throw new ServletException("Unable to load PMF properties.", ex);
} catch (JDOException ex) {
throw new ServletException("Unable to create PMF resource.", ex);
} catch (Exception ex) {
throw new ServletException("Unable to initialize.", ex);
}
|
protected void | processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Processes requests for both HTTP GET
and POST methods.
pm = persistenceManagerFactory.getPersistenceManager();
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body>");
out.print(formatMovieInfo());
out.println("</body>");
out.println("</html>");
out.close();
pm.close();
|