您的位置:首页网页设计JSP实例 → jsp源码实例2(获取表单参数)

jsp源码实例2(获取表单参数)

时间:2004/11/7 3:38:00来源:本站整理作者:蓝点我要评论(0)

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.

*



* Taken from Core Servlets and JavaServer Pages

* from Prentice Hall and Sun Microsystems Press,

* http://www.coreservlets.com/.

* © 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) +

"\n" +

"

" + title + "

\n" +

"\n" +

"\n" +

"
Parameter NameParameter Value(s)");

Enumeration paramNames = request.getParameterNames();

while(paramNames.hasMoreElements()) {

String paramName = (String)paramNames.nextElement();

out.print("
" + paramName + "\n");

String[] paramValues =

request.getParameterValues(paramName);

if (paramValues.length == 1) {

String paramValue = paramValues[0];

if (paramValue.length() == 0)

out.println("No Value");

else

out.println(paramValue);

} else {

out.println("
    ");

    for(int i=0; i
    out.println("
  • " + paramValues);

    }

    out.println("
");

}

}

out.println("
\n");

}



public void doPost(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

doGet(request, response);

}

}

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 没有查询到任何记录。 学习java必学的几门技术jspSmartUpload上传下载全攻略Tomcat5.x中的虚拟主机配置方法利用iText在JSP中生成PDF报表

人气排行 告诉大家JSP连接数据库程序代码JSP单页面网站文件管理器jsp留言板源代码一: 给jsp初学者.在jsp中用bean和servlet联合实现用户注册、使用JSP + JAVABEAN + XML 开发的一个例子jsp在线考试系统-jsp文件 jsp计数器代码JSP/JAVABEAN+TOMCAT4.0.5+MYSQL组合建站总