时间:2021-05-26
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
/** Shows all 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:///.
* © 2000 Marty Hall; may be 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(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\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);
}
}
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1:表单提交controller获得中文参数后乱码解决方案注意:jsp页面编码设置为UTF-8***************form表单提交方式为必须为post
本文实例讲述了JSP实现用于自动生成表单标签html代码的自定义表单标签。分享给大家供大家参考。具体如下:这个是自己写的一个简单的JSP表单标签,用于自动生成c
复制代码代码如下:JSP和JSTL获取服务器参数JSP方式 JSTL方式${pageContext.request}|取得请求对象${pageCont
jsp标签:实现请求转发给上面的添加参数的EL表达式:1.获取变量数据你好,${name}2.获取数组数据你好,${names[0]}3.获取集合数据你好,${
HTML: a.jsp: 页面间链接和数据传递的三种方式 (1)通过JSP表单形式将数据提交到dao下一个页面; (2)通过JSP表单链接将数据提交