java和jsp中的request使用示例

代码如下:

//== JAVA request 详细说明==
 System.out.println("rotocol: " + request.getProtocol());
 System.out.println("Scheme: " + request.getScheme());
 System.out.println("Server Name: " + request.getServerName() );
 System.out.println("Server Port: " + request.getServerPort());
 System.out.println("rotocol: " + request.getProtocol());
 System.out.println("Server Info: " + getServletConfig().getServletContext().getServerInfo());
 System.out.println("Remote Addr: " + request.getRemoteAddr());
 System.out.println("Remote Host: " + request.getRemoteHost());
 System.out.println("Character Encoding: " + request.getCharacterEncoding());
 System.out.println("Content Length: " + request.getContentLength());
 System.out.println("Content Type: "+ request.getContentType());
 System.out.println("Auth Type: " + request.getAuthType());
 System.out.println("HTTP Method: " + request.getMethod());
 System.out.println("ath Info: " + request.getPathInfo());
 System.out.println("ath Trans: " + request.getPathTranslated());
 System.out.println("Query String: " + request.getQueryString());
 System.out.println("Remote User: " + request.getRemoteUser());
 System.out.println("Session Id: " + request.getRequestedSessionId());
 System.out.println("Request URI: " + request.getRequestURI());
 System.out.println("Servlet Path: " + request.getServletPath());
 System.out.println("Accept: " + request.getHeader("Accept"));
 System.out.println("Host: " + request.getHeader("Host"));
 System.out.println("Referer : " + request.getHeader("Referer"));
 System.out.println("Accept-Language : " + request.getHeader("Accept-Language"));
 System.out.println("Accept-Encoding : " + request.getHeader("Accept-Encoding"));
 System.out.println("User-Agent : " + request.getHeader("User-Agent"));
 System.out.println("Connection : " + request.getHeader("Connection"));
 System.out.println("Cookie : " + request.getHeader("Cookie"));
 System.out.println("Created : " + session.getCreationTime());
 System.out.println("LastAccessed : " + session.getLastAccessedTime());

// ==JSP request 详细说明==

out.println("Protocol: " + request.getProtocol());
 out.println("Scheme: " + request.getScheme());
 out.println("Server Name: " + request.getServerName() );
 out.println("Server Port: " + request.getServerPort());
 out.println("Protocol: " + request.getProtocol());
 out.println("Server Info: " + getServletConfig().getServletContext().getServerInfo());
 out.println("Remote Addr: " + request.getRemoteAddr());
 out.println("Remote Host: " + request.getRemoteHost());
 out.println("Character Encoding: " + request.getCharacterEncoding());
 out.println("Content Length: " + request.getContentLength());
 out.println("Content Type: "+ request.getContentType());
 out.println("Auth Type: " + request.getAuthType());
 out.println("HTTP Method: " + request.getMethod());
 out.println("Path Info: " + request.getPathInfo());
 out.println("Path Trans: " + request.getPathTranslated());
 out.println("Query String: " + request.getQueryString());
 out.println("Remote User: " + request.getRemoteUser());
 out.println("Session Id: " + request.getRequestedSessionId());
 out.println("Request URI: " + request.getRequestURI());
 out.println("Servlet Path: " + request.getServletPath());
 out.println("Accept: " + request.getHeader("Accept"));
 out.println("Host: " + request.getHeader("Host"));
 out.println("Referer : " + request.getHeader("Referer"));
 out.println("Accept-Language : " + request.getHeader("Accept-Language"));
 out.println("Accept-Encoding : " + request.getHeader("Accept-Encoding"));
 out.println("User-Agent : " + request.getHeader("User-Agent"));
 out.println("Connection : " + request.getHeader("Connection"));
 out.println("Cookie : " + request.getHeader("Cookie"));
 out.println("Created : " + session.getCreationTime());
 out.println("LastAccessed : " + session.getLastAccessedTime());

(0)

相关推荐

  • 通过过滤器(Filter)解决JSP的Post和Request中文乱码问题

    jsp代码: import javax.servlet.*; import javax.servlet.http.*; public class CharsetFilter implements Filter { public void destroy() { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { try { HttpServletRequest

  • JSP XMLHttpRequest动态无刷新及其中文乱码处理

    1.在页面的<script type="text/JavaScript" >内加入 //无刷新请求的xmlhttp请求 var http_request=false; function createRequest(url) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_reque

  • JSP的request对象实例详解

    JSP的request对象实例详解 一 request对象定义 客户端的请求信息被封装在request对象中,通过它才能了解客户的需求,然后做出响应.它是HttpServletRequest类的实例.request对象具有请求域,即完成客户端的请求之前,该对象一直有效. 二 request对象方法 三 实例 <%@ page language="java" import="java.util.*" contentType="text/html; ch

  • JSP request(return String)用法详例

    1.JSP代码 : 复制代码 代码如下: <%-- Document : index Created on : 2009-10-4, 12:45:43 Author : lucifer --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN&

  • JSP用过滤器解决request getParameter中文乱码问题

    (1)客户端的数据一般是通过HTTP GET/POST方式提交给服务器,在服务器端用request.getParameter()读取参数时,很容易出现中文乱码现象. (2)用过滤器解决request中文乱码问题. (3)代码如下: package my; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ChineseFilter implements Filter { //定义

  • JSP request.setAttribute()详解及实例

     javascript request.setAttribute()详解 request.setAttribute()怎么用的? JSP1代码 String [] test=new String[2]; test[0]="1"; test[1]="2"; request.setAttribute("test",test) ; response.sendRedirect("jsp2.jsp"); JSP2代码 String te

  • jsp 对request.getSession(false)的理解(附程序员常疏忽的一个漏洞)

    [前面的话] 在网上经常看到有人对request.getSession(false)提出疑问,我第一次也很迷惑,看了一下J2EE1.3 API,看一下官网是怎么解释的. [官方解释] getSession public HttpSession getSession(boolean create) Returns the current HttpSession associated with this request or, if if there is no current session an

  • JSP利用过滤器解决request中文乱码问题

    本文为大家分享了JSP用过滤器解决request中文乱码问题,具体内容如下 (1)客户端的数据一般是通过HTTP  GET/POST方式提交给服务器,在服务器端用request.getParameter() 读取参数时,很容易出现中文乱码现象. (2)用过滤器解决request中文乱码问题. (3)代码如下: package my; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public clas

  • JSP内置对象:Request和Response的简单介绍及使用

    JSP内置对象之request对象客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应.它是HttpServletRequest类的实例.序号 方 法 说 明 1 object getAttribute(String name) 返回指定属性的属性值 2 Enumeration getAttributeNames() 返回所有可用属性名的枚举 3 String getCharacterEncoding() 返回字符编码方式 4 int getContentLen

  • jsp跳转getRequestDispatcher()和sendRedirect()的区别

    1.request.getRequestDispatcher()是请求转发,前后页面共享一个request ;response.sendRedirect()是重新定向,前后页面不是一个request. 2.RequestDispatcher.forward()是在服务器端运行;HttpServletResponse.sendRedirect()是通过向客户浏览器发送命令来完成.所以RequestDispatcher.forward()对于浏览器来说是"透明的":而HttpServlet

随机推荐