Js
Package coreservlets;
Import java.io.*;
Import javax.servlet.*;
Import javax.servlet.http.*;
Import java.util.*;
/** shows the parameters sent to the servlet via either
* Get or POST. Specially marks parameters that have
* No values or multiple values.
* <P>
* Taken from Core Servlets and JavaServer Pages
* FROM Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
*©2000 Marty Hall; May is freely used or adapted.
*/
public class Showparameters extends HttpServlet {
public void doget (HttpServletRequest request,
HttpServletResponse response)
Throws Servletexception, IOException {
Response.setcontenttype ("text/html");
PrintWriter out = Response.getwriter ();
String title = "Reading all Request Parameters";
Out.println (title) + Servletutilities.headwithtitle
"<body bgcolor=\" #FDF5E6 \ ">\n" +
"
"<table border=1 align=center>\n" +
"<tr bgcolor=\" #FFAD00 \ ">\n" +
"<th>parameter Name<th>parameter Value (s)");
Enumeration paramnames = Request.getparameternames ();
while (Paramnames.hasmoreelements ()) {
String paramname = (string) paramnames.nextelement ();
Out.print ("<TR><TD>" + paramname + "\n<td>");
string[] Paramvalues =
Request.getparametervalues (paramname);
if (paramvalues.length = = 1) {
String paramvalue = paramvalues[0];
if (paramvalue.length () = = 0)
Out.println ("<i>no value</i>");
Else
Out.println (paramvalue);
} else {
Out.println ("<UL>");
for (int i=0; i<paramvalues.length; i++) {
Out.println ("<LI>" + paramvalues);
}
Out.println ("</UL>");
}
}
Out.println ("</TABLE>\n</BODY></HTML>");
}
public void DoPost (HttpServletRequest request,
HttpServletResponse response)
Throws Servletexception, IOException {
Doget (request, response);
}
}