1 19 24 25 package org.netbeans.test.examples.logging; 26 27 import java.io.IOException ; 28 import java.io.PrintWriter ; 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 39 public class TestingServlet extends HttpServlet { 40 41 45 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 46 throws ServletException , IOException { 47 response.setContentType("text/html;charset=UTF-8"); 48 PrintWriter out = response.getWriter(); 49 out.println("<html>"); 50 out.println("<head>"); 51 out.println("<title>Servlet TestingServlet</title>"); 52 out.println("</head>"); 53 out.println("<body>"); 54 out.println("<h1>Servlet TestingServlet at " + request.getContextPath() + "</h1>"); 55 boolean b = false; 56 Exception e = null; 57 try { 58 getBGTransPort().BGTranslate("Hello"); 59 b = true; 60 } catch(java.rmi.RemoteException ex) { 61 e = ex; 63 } 64 if (b) { 65 out.println("<strong>Call was successful.</strong>"); 66 } else { 67 out.println("<strong>Call was not successful!!!</strong>"); 68 out.println("<br/><br/>"); 69 e.printStackTrace(out); 70 } 71 out.println("</body>"); 72 out.println("</html>"); 73 out.close(); 74 } 75 76 81 protected void doGet(HttpServletRequest request, HttpServletResponse response) 82 throws ServletException , IOException { 83 processRequest(request, response); 84 } 85 86 90 protected void doPost(HttpServletRequest request, HttpServletResponse response) 91 throws ServletException , IOException { 92 processRequest(request, response); 93 } 94 95 97 public String getServletInfo() { 98 return "Short description"; 99 } 100 102 private org.netbeans.test.examples.logging.BGTrans getBGTrans() { 103 org.netbeans.test.examples.logging.BGTrans bGTrans = null; 104 try { 105 javax.naming.InitialContext ic = new javax.naming.InitialContext (); 106 bGTrans = (org.netbeans.test.examples.logging.BGTrans) ic.lookup("java:comp/env/service/BGTrans"); 107 } catch(javax.naming.NamingException ex) { 108 } 110 return bGTrans; 111 } 112 113 private org.netbeans.test.examples.logging.BGTransPortType getBGTransPort() { 114 org.netbeans.test.examples.logging.BGTransPortType bGTransPort = null; 115 try { 116 bGTransPort = getBGTrans().getBGTransPort(); 117 } catch(javax.xml.rpc.ServiceException ex) { 118 } 120 return bGTransPort; 121 } 122 } 123 | Popular Tags |