HttpServletRequest is Interface use to reterive information from the client for HTTP servlet.

HttpServletRequest methods

Method Description
String a=getParameter("userid"); Return value of a request Parameter as a String ,or null if parameter does not exist.
String hobbies[]=
Returns an array of String Objects Containing all of values the given request has,or null if parameter does not exist
Enumeration e=
Returns an Enumeration of string Objects Containing the names of parameters contained in this request.If the request has no parameter,the methods returns an empty Enumeration.
String a=request.getProtocol(); Returns the names and version of protocolthe request uses in form of protocol/major Version,minor Version,for e.g HTTP//1.1
String header=
request.getHeader(String header name);
Returns the value of specified request header as a string.if the request did not include header of specified,this method returns null.the Header is case-insensitive.
Enumeration e=request.getHeaderNames(); Returns all the values of specified request header as an enumeration of String Objects.
String a=request.getMethod(); returns the name of HTTP method with which this request was made,e.g GET, POST etc.
HttpSession session
Returns the current session associated with this request,or if the request does not have session,creates one.
request.setAttribute(String name,Object o); Stores an attribute in this request.Attribute are reset between requests.this method is most often used in conjuction with RequestDispatcher.
Request.getAttribute(String name); Returns the value of named attribute as an Object,or null if no attribute of given name exists.


HttpServletResponse Interface used to send response to the client.

HttpServletResponse methods

Method Description
PrintWriter pw=response.getWriter(); Returns a PrintWriter object that can send character text to client.
response.setContentType("text/html"); Sets the content type of response being sent to client.
response.sendRedirect(""); Sends a temporary redirect response to client using the specified redirect location url.
String Header Name,Header Value);
Set the response Header with given name and value.If Header had already been set,the new value overwritethe previous one.
response.encodeURL(String url); Encodes the specified URL by including the session ID in it,or,if encoding is not needed,returns the URL unchanged.
The implementation of the method includes the logic to determine whether the session ID needs to be encoded in the URL.e.g-if browser supports cookie,or session tracking is turned off,URL encoding is unecessary.