1 22 package org.jboss.test.classloader.scoping.override.web; 23 24 import java.io.IOException ; 25 import java.io.PrintWriter ; 26 import javax.servlet.http.HttpServlet ; 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.http.HttpServletResponse ; 29 import javax.servlet.ServletConfig ; 30 import javax.servlet.ServletException ; 31 import javax.naming.InitialContext ; 32 import javax.naming.Context ; 33 34 40 public class ENCServlet extends HttpServlet 41 { 42 47 public void init(ServletConfig servletConfig) throws ServletException 48 { 49 super.init(servletConfig); 50 } 51 52 protected void doGet(HttpServletRequest request, HttpServletResponse response) 53 throws ServletException , IOException 54 { 55 processRequest(request, response); 56 } 57 58 protected void doPost(HttpServletRequest request, HttpServletResponse response) 59 throws ServletException , IOException 60 { 61 processRequest(request, response); 62 } 63 64 private void processRequest(HttpServletRequest request, HttpServletResponse response) 65 throws ServletException , IOException 66 { 67 response.setContentType("text/html"); 68 PrintWriter pw = response.getWriter(); 69 pw.println("<html><head><title>ENCServlet Scoping Test</title></head>"); 70 pw.println("<body><h1>ENCServlet Scoping Test</h1>"); 71 72 try 73 { 74 InitialContext ctx = new InitialContext (); 75 Context env = (Context ) ctx.lookup("java:comp/env"); 76 pw.println("env = "+env); 77 String value1 = (String ) env.lookup("prop1"); 78 if( value1.equals("value1") == false ) 79 throw new IllegalStateException ("prop1 != value1, "+value1); 80 } 81 catch (Exception e) 82 { 83 throw new ServletException ("Failed to validate ENC", e); 84 } 85 pw.println("</body></html>"); 86 } 87 } 88 | Popular Tags |