JSP detailed Request Object

Source: Internet
Author: User

Request Object

The client's request information is encapsulated in the requests object to understand the customer's needs and respond. It is an instance of the HttpServletRequest class.

Ordinal method Description
1 Object getattribute (String name) returns the property value of the specified property
2 enumeration Getattributenames () returns an enumeration of all available property names
3 String getcharacterencoding () returns the character encoding method
4 int Getcontentlength () returns the length of the request body (in bytes)
5 String getContentType () Gets the MIME type of the request body
6 ServletInputStream getInputStream () gets the binary stream of a row in the request body
7 string GetParameter (string name) returns the parameter value of name specified parameter
8 enumeration Getparameternames () returns an enumeration of the available parameter names
9 string[] Getparametervalues (String name) returns an array of all values that contain the parameter name
Ten String Getprotocol () returns the protocol type and version number of the request
One String Getscheme () returns the plan name of the request, such as: Http.https and FTP, etc.
String getServerName () returns the host name of the server that accepts the request
int Getserverport () returns the port number used by the server to accept this request
BufferedReader Getreader () returns the decoded request body
String getremoteaddr () returns the IP address of the client that sent this request
String Getremotehost () returns the host name of the client that sent this request
$ void SetAttribute (String key,object obj) to set property values for a property
String Getrealpath (string path) returns the true path of a virtual path
19
20

<%@ page contenttype= "text/html;charset=gb2312"%>
<%request.setcharacterencoding ("gb2312");%>
<title>request a00-206 </title>
<body bgcolor= "#FFFFF0" >
<form action= "" method= "POST" >
<input type= "text" name= "Qwe" >
<input type= "Submit" value= "Submission" >
</form>
Request method: <%=request.getmethod ()%><br>
Requested resource: <%=request.getrequesturi ()%><br>
Requested protocol: <%=request.getprotocol ()%><br>
Requested file name: <%=request.getservletpath ()%><br>
Ip:<%=request.getservername ()%><br> of the requested server
Port of the requesting server: <%=request.getserverport ()%><br>
Client IP Address: <%=request.getremoteaddr ()%><br>
Client host Name: <%=request.getremotehost ()%><br>
Value submitted by Form: <%=request.getparameter ("Qwe")%><br>
</body>
<%@ page contenttype= "text/html;charset=gb2312"%>
<%request.setcharacterencoding ("gb2312");%>
<%@ page import= "Java.util.Enumeration"%>
<title>request 250-10 </title>
<body bgcolor= "#FFFFF0" >
<form action= "" method= "POST" >
User name: <input type= "text" name= "username" >&nbsp;&nbsp;
Password: <input type= "text" name= "Userpass" >&nbsp;&nbsp;
<input type= "Submit" value= "enter" >
</form>
<%
String str= "";
if (Request.getparameter ("username")!=null && request.getparameter ("Userpass")!=null) {
Enumeration enumt = Request.getparameternames ();
while (Enumt.hasmoreelements ()) {
Str=enumt.nextelement (). toString ();
Out.println (str+ ":" +request.getparameter (str) + "<br>");
}
}
%>
</body>
<%@ page contenttype= "text/html;charset=gb2312"%>
<%request.setcharacterencoding ("gb2312");%>
<title> e20-090 </title>
<body bgcolor= "#FFFFF0" >
<form action= "" method= "POST" >
Good: <input type= "checkbox" Name= "CB" value= "ON1" >VC++&nbsp;
<input type= "checkbox" Name= "CB" value= "ON2" >JAVA&nbsp;
<input type= "checkbox" Name= "CB" value= "ON3" >DELPHI&nbsp;
<input type= "checkbox" Name= "CB" value= "ON4" >VB&nbsp;
<br>
<input type= "Submit" value= "enter" Name= "Qwe" >
</form>
<%
if (Request.getparameter ("Qwe")!=null) {
for (int i=0;i<request.getparametervalues ("CB"). length;i++) {
OUT.PRINTLN ("CB" +i+ ":" +request.getparametervalues ("CB") [i]+ "<br>");
}
Out.println (Request.getparameter ("qwe"));
}
%>
</body>

JSP detailed Request Object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.