1 22 package org.jboss.injbossaop.web; 23 24 import java.io.IOException ; 25 26 import javax.naming.InitialContext ; 27 import javax.naming.NamingException ; 28 import javax.rmi.PortableRemoteObject ; 29 import javax.servlet.ServletException ; 30 import javax.servlet.http.HttpServlet ; 31 import javax.servlet.http.HttpServletRequest ; 32 import javax.servlet.http.HttpServletResponse ; 33 34 import org.jboss.injbossaop.ejb.ExampleSession; 35 import org.jboss.injbossaop.ejb.ExampleSessionHome; 36 import org.jboss.injbossaop.lib.ExampleValue; 37 38 43 public class EarExampleServlet extends HttpServlet { 44 45 public void service(HttpServletRequest request, HttpServletResponse response) 46 throws ServletException , IOException { 47 try 48 { 49 String s = request.getParameter("field1"); 50 System.out.println("**** EarExampleServlet.service()"); 51 52 InitialContext ctx = new InitialContext (); 53 Object obj = ctx.lookup("ExampleSession"); 54 ExampleSessionHome home = (ExampleSessionHome)PortableRemoteObject.narrow(obj, ExampleSessionHome.class); 55 ExampleSession exSess = home.create(); 56 ExampleValue value = exSess.getValue(s); 57 58 request.getSession().setAttribute("exampleValue", new ExampleValue(s)); 59 request.getRequestDispatcher("/index.jsp").forward(request, response); 60 } 61 catch (Exception e) 62 { 63 e.printStackTrace(); 64 throw new ServletException (e); 65 } 66 } 67 } 68 | Popular Tags |