jsp源码之获取jsp各种参数代码

来源:爱站网时间:2020-09-23编辑:网友分享
编写jsp源码前,需要技术人员熟练的掌握相关知识,这样在操作的时候才能更顺畅的编写,下面爱站技术频道小编给大家讲解下jsp源码之获取jsp各种参数代码。

编写jsp源码前,需要技术人员熟练的掌握相关知识,这样在操作的时候才能更顺畅的编写,下面爱站技术频道小编给大家讲解下jsp源码之获取jsp各种参数代码。

package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

/** Creates a table showing the current value of each
* of the standard CGI variables.
*


* 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 ShowCGIVariables extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String[][] variables =
{ { "AUTH_TYPE", request.getAuthType() },
{ "CONTENT_LENGTH",
String.valueOf(request.getContentLength()) },
{ "CONTENT_TYPE", request.getContentType() },
{ "DOCUMENT_ROOT",
getServletContext().getRealPath("/") },
{ "PATH_INFO", request.getPathInfo() },
{ "PATH_TRANSLATED", request.getPathTranslated() },
{ "QUERY_STRING", request.getQueryString() },
{ "REMOTE_ADDR", request.getRemoteAddr() },
{ "REMOTE_HOST", request.getRemoteHost() },
{ "REMOTE_USER", request.getRemoteUser() },
{ "REQUEST_METHOD", request.getMethod() },
{ "SCRIPT_NAME", request.getServletPath() },
{ "SERVER_NAME", request.getServerName() },
{ "SERVER_PORT",
String.valueOf(request.getServerPort()) },
{ "SERVER_PROTOCOL", request.getProtocol() },
{ "SERVER_SOFTWARE",
getServletContext().getServerInfo() }
};
String title = "Servlet Example: Showing CGI Variables";
out.println(ServletUtilities.headWithTitle(title) +
"

\n" +
"

" + title + "

\n" +
"\n" +
"\n" +
"

CGI Variable Name Value");
for(int i=0; i String varName = variables[0];
String varValue = variables[i][1];
if (varValue == null)
varValue = "Not specified";
out.println("
" + varName + " " + varValue);
}
out.println("

学习完jsp源码之获取jsp各种参数代码内容后,希望小伙伴们能记在心中哦,只有记牢了,才是自己的东西,有问题可以随时@小编哦!

上一篇:jsp初学者必学代码第一章

下一篇:jsp源码之获取表单参数代码

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载