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
00046 public class TestServletServlet extends HttpServlet {
00047 static final long serialVersionUID = 5521257935120563452L;
00048
00049
00050
00051
00052
00053
00054
00055 public TestServletServlet() {
00056 }
00057
00058 public void init() throws ServletException {
00059 }
00060
00061 public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00062 this.processRequest(req, res);
00063 }
00064
00075 public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00076 this.processRequest(req, res);
00077 }
00078
00079 private void processRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
00080 res.setContentType("text/html");
00081
00082 StringBuffer sb = new StringBuffer(200);
00083
00084
00085
00086 sb.append("<HTML>\n").append("<HEAD><TITLE>Test Servlet</TITLE></HEAD>\n")
00087 .append("<BODY>\n")
00088 .append("ServletInfo : "+this.getServletInfo())
00089 .append("\n<br>\nServletName : "+this.getServletName())
00090 .append("\n<br>\nMajor version : "+this.getServletContext().getMajorVersion())
00091 .append("\n<br>\nMinor version : "+this.getServletContext().getMinorVersion())
00092 .append("\n<br>\nInit Parameters");
00093
00094 Enumeration enuma = this.getInitParameterNames();
00095 while (enuma.hasMoreElements()) {
00096 String parameterName = (String)enuma.nextElement();
00097 String parameterValue = this.getInitParameter(parameterName);
00098 sb.append("\n <br> Name : "+parameterName);
00099 sb.append("\n <br> Value : "+parameterValue);
00100 }
00101
00102 sb.append("\n<br>\nAttributes");
00103 enuma = this.getServletContext().getAttributeNames();
00104 while (enuma.hasMoreElements()) {
00105 String attributeName = (String)enuma.nextElement();
00106 String attributeValue = this.getInitParameter(attributeName);
00107 sb.append("\n <br> Name : "+attributeName);
00108 sb.append("\n <br> Value : "+attributeValue);
00109 }
00110
00111 sb.append("\n<br>\nServer info : "+this.getServletContext().getServerInfo())
00112 .append("\n<br>\nServletContextName : "+this.getServletContext().getServletContextName())
00113 .append("\n</BODY></HTML>\n");
00114
00115
00116 PrintWriter out = res.getWriter();
00117
00118
00119 out.print(sb.toString());
00120 }
00121
00122 }