获取jsp参数深度详解

来源:爱站网时间:2018-09-28编辑:网友分享
今天小编给大家分享一篇获取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[i][0];

  String varValue = variables[i][1];

  if (varValue == null)

  varValue = "Not specified";

  out.println("

" + varName + " " + varValue);

 

  }

  out.println("

");

 

  }

  /** POST and GET requests handled identically. */

  public void doPost(HttpServletRequest request,

  HttpServletResponse response)

  throws ServletException, IOException {

  doGet(request, response);

  }

  }

  以上就是获取jsp参数深度详解,想必都了解了吧,更多相关内容请继续关注爱站技术频道。

上一篇:linux系统建设jsp环境的详细教程

下一篇:用js绘图的详细教程

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载