01: package org.lateralnz.demo.view;
02:
03: import java.io.*;
04: import java.net.*;
05: import java.util.*;
06:
07: import javax.servlet.*;
08: import javax.servlet.http.*;
09:
10: import org.lateralnz.common.util.JNDIUtils;
11:
12: import org.lateralnz.demo.ejb.Basic;
13: import org.lateralnz.demo.ejb.BasicHome;
14:
15: public class BasicServlet extends HttpServlet {
16:
17: public void init(ServletConfig config) throws ServletException {
18: super .init(config);
19: }
20:
21: public void destroy() {
22: }
23:
24: protected void doGet(HttpServletRequest request,
25: HttpServletResponse response) throws ServletException,
26: IOException {
27: PrintWriter out = null;
28: Basic basicejb = null;
29:
30: try {
31: response.setContentType("text/html");
32: out = response.getWriter();
33: BasicHome home = (BasicHome) JNDIUtils.getEJBHome(
34: "DEMO/Basic", BasicHome.class);
35: basicejb = home.create();
36:
37: int rand = basicejb.getRandom(100000);
38:
39: List list = basicejb.getList();
40:
41: out.println("<html><body>\n");
42: out.println("<p>" + rand + "</p>\n");
43: out.println("<p>" + list + "</p>\n");
44: out.println("</body></html>");
45: } catch (Exception e) {
46: throw new ServletException(e.getMessage(), e);
47: } finally {
48: JNDIUtils.remove(basicejb);
49: out.close();
50: }
51: }
52:
53: public String getServletInfo() {
54: return "basic demo";
55: }
56:
57: }
|