Jsp request

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>   <head>     <base href="<%=basePath%>">         <title>My JSP ‘index.jsp‘ starting page</title>  <meta http-equiv="pragma" content="no-cache">  <meta http-equiv="cache-control" content="no-cache">  <meta http-equiv="expires" content="0">     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  <meta http-equiv="description" content="This is my page">  <!--  <link rel="stylesheet" type="text/css" href="styles.css">  -->   </head>     <body>     <form action="show.jsp" method="post">     <ul style="list-style;none;line-height:30px">           <li>输入用户姓名:    <input type="text" name="name3"/><br/></li>             <li>Selet Sex:             <input name="sex" type="radio" value="Male"/>Man             <input name="sex" type="radio" value="Female" />Female        </li>               <li> selet password question:           <select name="question">             <option value="mother birthday:">Mother birthday:</option>             <option value="Pet name">Pet name</option>                    </select>        </li>        <li>请输入问题答案: <input type="text" name="key"/>  </li>         <li>selet your habit:          <div>            <input name="like" type="checkbox" value="Singing and dancing" />Singing and dancing            <input name="like" type="checkbox" value="surf on the Internet" />urf on the Internet            <input name="like" type="checkbox" value="Climb" />Climb            <input name="like" type="checkbox" value="Reading" />Reading           </div>       </li>        <li><input type="submit" value="Submit"/>                          </ul>                 </form>     <ul style="line-height:24px">       <li>客户使用的协议:<%=request.getProtocol() %></li>       <li>客户端发送请求的方法:<%=request.getMethod() %></li>       <li>客户端请求路径:<%=request.getContextPath() %></li>       <li>客户机IP地址:<%=request.getRemoteAddr() %></li>       <li>客客户机名称:<%=request.getRemoteHost() %></li>       <li>客户机请求端口号:<%=request.getRemotePort() %></li>       <li>接受客户信息的页面:<%=request.getServletPath()%></li>       <li>获取报头中User-Aget值:<%=request.getHeader("user-agent") %></li>       <li>获取报头中Uaccept值:<%=request.getHeader("accept") %></li>       <li>获取报头中Host值:<%=request.getHeader("host") %></li>       <li>获取报头中accept-encoding值:<%=request.getHeader("accept-encoding") %></li>       <li>获取URI:<%=request.getRequestURI() %></i>       <li>获取URL:<%=request.getRequestURL()%></li>                       </ul>     </body> </html>

Jsp request

时间: 2024-08-11 07:40:17

Jsp request的相关文章

jsp Request获取url信息的各种方法比较

从Request对象中可以获取各种路径信息,以下例子: 假设请求的页面是index.jsp,项目是WebDemo,则在index.jsp中获取有关request对象的各种路径信息如下 String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+&q

jsp request 获取路径

这篇教程不错:http://zjutsoft.iteye.com/blog/1084260 自己试验如下: System.out.println("-----------------servlet-----------------"); System.out.println("realpath null:"+request.getRealPath("")); System.out.println("realpath index.jsp:

jsp request 对象详解

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

JSP request.setAttribute()详解及实例

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

jsp request response session application 的作用域和区别

首先他们的作用域, page:仅在当前页面有效可以通过'转发'把数据传送到其他页面.可以使用pageContext来获取.. request: 再一次服务器请求范围内有效,重定向第一次可以获取到 session:再一次回话内有效,简单来说在同一个浏览器面向一个用户sessionID都是同一个(在非隐私浏览器不管开多少子标签)有效, application:在所有浏览器所有用户都有效,只要tomcar服务不取消这个值都会被获取到. 刚刚入门的小学生欢迎各路大神教导! 原文地址:https://ww

JSP URI/URL - How to get the request URI, URL, and Context from a JSP

JSP URI/URL FAQ: How do I get a URI or URL from a JSP (the request URI or request URL)? I was just working with a JSP, and trying to remember how to get information that can be very helpful inside of a JSP, specifically how to determine the Context,

JSP学习笔记 - 内置对象 Request

1.主要掌握以下5个内置对象及其所属类,必须学会在java docs里根据类名查找相应的方法 request     javax.servlet.http.HttpServletRequest response  javax.servlet.http.HttpServletResponse session    javax.servlet.http.HttpSession pageContext  javax.servlet.jsp.PageContext application   javax

JSP中Request属性范围

JSP属性范围,通过以下几个测试代码来学习request属性的范围 测试一(JSP动态指令方式传参): 测试内容: <jsp:param .../>添加参数,通过<jsp:forward page="...">来实现服务器端跳转,以此来测试request属性的范围: 页面RequestScopeDemo.jsp (添加info1参数) -> 通过<jsp:forward page="RequestScopeDemo_1.jsp"&

Jsp重定向(response.sendRedirect())和转发(request.getRequestDispatcher().forward(request,r)的区别

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@page import="sun.awt.RepaintArea"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://&q