1 20 package org.enhydra.barracuda.examples.ex4; 21 22 import java.io.*; 23 import java.util.*; 24 import java.net.*; 25 import javax.servlet.*; 26 import javax.servlet.http.*; 27 28 import org.enhydra.barracuda.core.event.*; 29 import org.enhydra.barracuda.examples.ex4.events.*; 30 31 32 35 public class SampleViewHandler extends DefaultListenerFactory { 36 37 public static final String HANDLED_BY = "HandledBy"; 38 39 public BaseEventListener getInstance() { 41 return new RenderHandler(); 42 } 43 public String getListenerID() { 44 return getID(RenderHandler.class); 45 } 46 47 54 class RenderHandler extends DefaultBaseEventListener { 55 public void handleViewEvent(ViewEventContext context) throws EventException, ServletException, IOException { 56 BaseEvent event = context.getEvent(); 58 HttpServletResponse resp = context.getResponse(); 59 60 resp.setHeader("Cache-Control","max-age=0"); 63 resp.setDateHeader("Last-Modified", System.currentTimeMillis()); 64 65 resp.setContentType("text/html"); 67 PrintWriter out = resp.getWriter(); 68 69 String title = "Simple Deployment Descriptor Test Screen"; 71 out.println ("<html>"); 72 out.println (" <head>"); 73 out.println (" <title>"+title+"</title>"); 74 out.println (" </head>"); 75 out.println (" <body>"); 76 out.println (" <font face=\"Arial\">"); 77 78 out.println (" <p>"+title); 80 out.println (" <p>Handled by:"+context.getState(HANDLED_BY)); 81 82 out.println (" </font>"); 84 out.println (" </body>"); 85 out.println ("</html>"); 86 } 87 } 88 } 89 90 | Popular Tags |