Showing posts with label HTTP Response Headers Part II (Methods). Show all posts
Showing posts with label HTTP Response Headers Part II (Methods). Show all posts

18 Feb 2014

HTTP Response Headers Part II (Methods)

setHeader(String headerName, String headerValue)

This method sets the response header with the designated name to the given value.


setDateHeader(String header, long milliseconds)

This method saves you the trouble of translating a Java date in milliseconds since 1970 (as returned by System.currentTimeMillis, Date.getTime, or Calendar.getTimeInMillis) into a GMT time string. 


setIntHeader(String header, int headerValue)

This method spares you the minor inconvenience of converting an int to a String before inserting it into a header.


setContentType(String mimeType)

This method sets the Content-Type header and is used by the majority of servlets.


setContentLength(int length)

This method sets the Content-Length header, which is useful if the browser supports persistent (keep-alive) HTTP connections.


addCookie(Cookie c)

This method inserts a cookie into the Set-Cookie header. There is no corresponding setCookie method, since it is normal to have multiple Set-Cookie lines. 


sendRedirect(String address)

The sendRedirect method sets the Location header as well as setting the status code to 302.

Comments

© 2013-2016 ITTechnocrates. All rights resevered. Developed by Bhavya Mehta