1 6 11 12 package com.sun.javaee.blueprints.components.ui.example; 13 14 import java.io.*; 15 import java.net.*; 16 17 import javax.servlet.*; 18 import javax.servlet.http.*; 19 20 25 public class CompAServlet extends HttpServlet { 26 27 31 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 32 throws ServletException, IOException { 33 response.setContentType("text/xml;charset=UTF-8"); 34 PrintWriter out = response.getWriter(); 35 String itemId=request.getParameter("itemId"); 36 37 response.setHeader("Pragma", "No-Cache"); 38 response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); 39 response.setDateHeader("Expires", 1); 40 if(itemId != null) { 41 out.println("<response>"); 42 if(itemId.indexOf("test1") > -1) { 43 out.println("<title><![CDATA[" + itemId + " Lookup]]></title>"); 44 out.println("<message><![CDATA[<b>The itemId that is performing this lookup is '" + itemId + 45 "'.</b><br/><br/>This popup is trigger through the onmouseover and onmouseout event handlers. " + 46 "Since this popup request is fulfilled using a <b>Servlet</b>, there is an initial pause on the first request to load the class.]]></message>"); 47 } else { 48 out.println("<title><![CDATA[" + itemId + " Lookup]]></title>"); 49 out.println("<message><![CDATA[<b>The itemId that is performing this lookup is '" + itemId + 50 "'.</b><br/><br/>This popup is trigger through the onmouseover event handler and hidden when the user clicks on the 'CLOSE' link in the popup." + 51 "Since this popup request is fulfilled using a <b>Servlet</b>, there is an initial pause on the first request to load the class." + 52 "<br/><br/><span onclick=\"bpui.compA.hidePopup('pop1')\" style=\"z-index: 4; position: relative; cursor: pointer\"><b>[<u>CLOSE</u>]</b></span>" + 53 "]]></message>"); 54 } 55 out.println("</response>"); 56 } else { 57 out.println("<response>"); 58 out.println("<title><![CDATA[REQUEST ERROR]]></title>"); 59 out.println("<message><![CDATA[The query parameter 'itemId' required]]></message>"); 60 out.println("</response>"); 61 } 62 out.flush(); 63 out.close(); 64 } 65 66 71 protected void doGet(HttpServletRequest request, HttpServletResponse response) 72 throws ServletException, IOException { 73 processRequest(request, response); 74 } 75 76 80 protected void doPost(HttpServletRequest request, HttpServletResponse response) 81 throws ServletException, IOException { 82 processRequest(request, response); 83 } 84 85 87 public String getServletInfo() { 88 return "Short description"; 89 } 90 } 92 | Popular Tags |