About HttpServletRequest and HttpServletResponse in Servlets

Source: Internet
Author: User

1. HttpServletRequest

Method

Description

Getattributenames ()

Returns the name collection for all properties of the current request

GetAttribute (String name)

Returns the property value specified by name

GetCookies ()

Returns the cookie sent by the client

GetSession ()

Returns the session associated with the client and returns NULL if no session is assigned to the client

GetSession (Boolean Create)

Returns the session associated with the client and, if no session is assigned to the client, creates a session and returns

GetParameter (String name)

Gets the parameter in the request, which is specified by name

Getparametervalues (String name)

Returns the value of the parameter in the request, which is specified by name

Getcharacterencoding ()

Returns the character encoding of the request

Getcontentlength ()

Returns the effective length of the request body

getInputStream ()

Gets the data in the requested input stream

GetMethod ()

Gets the way the request is sent, such as GET, post

Getparameternames ()

Gets the name of all parameters in the request

Getprotocol ()

Gets the protocol name used by the request

Getreader ()

Gets the data flow of the request body

GETREMOTEADDR ()

Get the IP address of the client

Getremotehost ()

Get the name of the client

getServerName ()

Returns the name of the server that accepted the request

Getserverpath ()

Gets the path of the requested file

Common methods of HttpServletResponse

Method

Description

Addcookie (Cookie cookie)

Adds the specified cookie to the current response

AddHeader (String name,string value)

Adds the specified name and value to the header information of the response

Containsheader (String name)

Returns a Boolean value that determines whether the head of the response is set

Encodeurl (String URL)

Encode the specified URL

Senderror (int SC)

Sends an error to the client using the specified status code

Sendredirect (String location)

Send a temporary response to the client

Setdateheader (String name,long date)

Sets the given name and date to the head of the response

SetHeader (String name,string value)

Sets the given name and value to the head of the response

SetStatus (int SC)

Set the status code for the current response

setContentType (String ContentType)

Set the MIME type of the response

About HttpServletRequest and HttpServletResponse in Servlets

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.