00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 package org.openmobileis.embedded.webserver.test.services.servlet;
00031
00032 import java.io.IOException;
00033 import java.io.PrintWriter;
00034 import java.util.Enumeration;
00035
00036 import javax.servlet.ServletException;
00037 import javax.servlet.http.HttpServlet;
00038 import javax.servlet.http.HttpServletRequest;
00039 import javax.servlet.http.HttpServletResponse;
00040
00041 import org.openmobileis.common.context.ApplicationContextManager;
00042
00048 public class TestServletServlet extends HttpServlet {
00049
00050 private ApplicationContextManager applicationContextManager;
00051
00052
00053
00054
00055
00056
00057
00058 public TestServletServlet() {
00059 }
00060
00061 public void init() throws ServletException {
00062 }
00063
00064 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00065 this.processRequest(req, res);
00066 }
00067
00078 public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00079 this.processRequest(req, res);
00080 }
00081
00082 private void processRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00083 res.setContentType("text/html");
00084
00085 StringBuffer sb = new StringBuffer(200);
00086
00087
00088
00089 sb.append("<HTML>\n").append("<HEAD><TITLE>Test Servlet</TITLE></HEAD>\n")
00090 .append("<BODY>\n")
00091 .append("ServletInfo : "+this.getServletInfo())
00092 .append("\n<br>\nServletName : "+this.getServletName())
00093 .append("\n<br>\nMajor version : "+this.getServletContext().getMajorVersion())
00094 .append("\n<br>\nMinor version : "+this.getServletContext().getMinorVersion())
00095 .append("\n<br>\nInit Parameters");
00096
00097 Enumeration enum = this.getInitParameterNames();
00098 while (enum.hasMoreElements()) {
00099 String parameterName = (String)enum.nextElement();
00100 String parameterValue = this.getInitParameter(parameterName);
00101 sb.append("\n <br> Name : "+parameterName);
00102 sb.append("\n <br> Value : "+parameterValue);
00103 }
00104
00105 sb.append("\n<br>\nAttributes");
00106 enum = this.getServletContext().getAttributeNames();
00107 while (enum.hasMoreElements()) {
00108 String attributeName = (String)enum.nextElement();
00109 String attributeValue = this.getInitParameter(attributeName);
00110 sb.append("\n <br> Name : "+attributeName);
00111 sb.append("\n <br> Value : "+attributeValue);
00112 }
00113
00114 sb.append("\n<br>\nServer info : "+this.getServletContext().getServerInfo())
00115 .append("\n<br>\nServletContextName : "+this.getServletContext().getServletContextName())
00116 .append("\n</BODY></HTML>\n");
00117
00118
00119 PrintWriter out = res.getWriter();
00120
00121
00122 out.print(sb.toString());
00123 }
00124
00125 }