01: package clime.messadmin.example;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05:
06: import javax.servlet.http.HttpServletRequest;
07: import javax.servlet.http.HttpServletResponse;
08:
09: import clime.messadmin.core.Constants;
10:
11: /**
12: * Sample Servlet which does nothing!
13: * @author Cédrik LIME
14: */
15: public class SampleServlet extends BaseSample {
16:
17: /**
18: * @see javax.servlet.http.HttpServlet#HttpServlet()
19: */
20: public SampleServlet() {
21: super ();
22: }
23:
24: /**
25: * {@inheritDoc}
26: */
27: public void process(HttpServletRequest req, HttpServletResponse resp)
28: throws IOException {
29: doSomeWork(req, resp);
30: PrintWriter out = resp.getWriter();
31: out.println("<html>");
32: out
33: .println("<head><title>Hello, world (Servlet version)!</title>");
34: out.println("<body>");
35: out.println("<h1>Hello, World (Servlet version)!</h1>");
36: out.print("My Session Id: ");
37: out.println(req.getSession().getId());
38: out.println("<br />");
39: out.print("My Locale: ");
40: out.println(getLocale(req));
41: out.println("<br />");
42: out.print("Global attribute present: ");
43: out.println(getServletContext().getAttribute(
44: Constants.GLOBAL_MESSAGE_KEY) != null);
45: out.println("<br />");
46: out.print("Session attribute present: ");
47: out.println(req.getSession().getAttribute(
48: Constants.SESSION_MESSAGE_KEY) != null);
49: out.println("<br />");
50: out.print("Current simulated workload: ");
51: out.print(getWorkload(req));
52: out.println(" ms");
53: out.println("</body></html>");
54: }
55: }
|