最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > jsp教程

jsp开发:获取jsp各种参数

日期:10-20    来源:中国设计秀    作者:cnwebshow.com

package coreservlets; p73中国设计秀
p73中国设计秀
import java.io.*; p73中国设计秀
import javax.servlet.*; p73中国设计秀
import javax.servlet.http.*; p73中国设计秀
import java.util.*; p73中国设计秀
p73中国设计秀
/** Creates a table showing the current value of each p73中国设计秀
* of the standard CGI variables. p73中国设计秀
* <P> p73中国设计秀
* Taken from Core Servlets and JavaServer Pages p73中国设计秀
* from PRentice Hall and Sun Microsystems Press, p73中国设计秀
* http://www.coreservlets.com/. p73中国设计秀
* &copy; 2000 Marty Hall; may be freely used or adapted. p73中国设计秀
*/ p73中国设计秀
p73中国设计秀
public class ShowCGIVariables extends HttpServlet { p73中国设计秀
public void doGet(HttpServletRequest request, p73中国设计秀
HttpServletResponse response) p73中国设计秀
throws ServletException, IOException { p73中国设计秀
response.setContentType("text/html"); p73中国设计秀
PrintWriter out = response.getWriter(); p73中国设计秀
String[][] variables = p73中国设计秀
{ { "AUTH_TYPE", request.getAuthType() }, p73中国设计秀
{ "CONTENT_LENGTH", p73中国设计秀
String.valueOf(request.getContentLength()) }, p73中国设计秀
{ "CONTENT_TYPE", request.getContentType() }, p73中国设计秀
{ "DOCUMENT_ROOT", p73中国设计秀
getServletContext().getRealPath("/") }, p73中国设计秀
{ "PATH_INFO", request.getPathInfo() }, p73中国设计秀
{ "PATH_TRANSLATED", request.getPathTranslated() }, p73中国设计秀
{ "QUERY_STRING", request.getQueryString() }, p73中国设计秀
{ "REMOTE_ADDR", request.getRemoteAddr() }, p73中国设计秀
{ "REMOTE_HOST", request.getRemoteHost() }, p73中国设计秀
{ "REMOTE_USER", request.getRemoteUser() }, p73中国设计秀
{ "REQUEST_METHOD", request.getMethod() }, p73中国设计秀
{ "SCRipT_NAME", request.getServletPath() }, p73中国设计秀
{ "SERVER_NAME", request.getServerName() }, p73中国设计秀
{ "SERVER_PORT", p73中国设计秀
String.valueOf(request.getServerPort()) }, p73中国设计秀
{ "SERVER_PROTOCOL", request.getProtocol() }, p73中国设计秀
{ "SERVER_SOFTWARE", p73中国设计秀
getServletContext().getServerInfo() } p73中国设计秀
}; p73中国设计秀
String title = "Servlet Example: Showing CGI Variables"; p73中国设计秀
out.println(ServletUtilities.headWithTitle(title) + p73中国设计秀
"<BODY BGCOLOR="#FDF5E6">n" + p73中国设计秀
"<H1 ALIGN="CENTER">" + title + "</H1>n" + p73中国设计秀
"<TABLE BORDER=1 ALIGN="CENTER">n" + p73中国设计秀
"<TR BGCOLOR="#FFAD00">n" + p73中国设计秀
"<TH>CGI Variable Name<TH>Value"); p73中国设计秀
for(int i=0; i<variables.length; i++) { p73中国设计秀
String varName = variables[i][0]; p73中国设计秀
String varValue = variables[i][1]; p73中国设计秀
if (varValue == null) p73中国设计秀
varValue = "<I>Not specified</I>"; p73中国设计秀
out.println("<TR><TD>" + varName + "<TD>" + varValue); p73中国设计秀
} p73中国设计秀
out.println("</TABLE></BODY></HTML>"); p73中国设计秀
} p73中国设计秀
p73中国设计秀
/** POST and GET requests handled identically. */ p73中国设计秀
p73中国设计秀
public void doPost(HttpServletRequest request, p73中国设计秀
HttpServletResponse response) p73中国设计秀
throws ServletException, IOException { p73中国设计秀
doGet(request, response); p73中国设计秀
} p73中国设计秀
} p73中国设计秀
p73中国设计秀
p73中国设计秀
p73中国设计秀
p73中国设计秀
p73中国设计秀
 p73中国设计秀

本文引用地址:/bc/article_46782.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明