The HttpServletResponse Object:
The response object is an instance of a javax.servlet.http.HttpServletRequest object. Just as the server creates the request object, it also creates an object to represent the response to the client.
The response object also defines the interfaces that deal with creating new HTTP headers. Through this object the JSP programmer can add new cookies or date stamps, HTTP status codes etc.
There are following methods which can be used to set HTTP response header in your servlet program. These method are available with HttpServletResponse object which represents server response.
|
S.N. |
Method & Description |
|
1 |
String encodeRedirectURL(String url) |
|
2 |
String encodeURL(String url) |
|
3 |
boolean containsHeader(String name) |
|
4 |
boolean isCommitted() |
|
5 |
void addCookie(Cookie cookie) |
|
6 |
void addDateHeader(String name, long date) |
|
7 |
void addHeader(String name, String value) |
|
8 |
void addIntHeader(String name, int value) |
|
9 |
void flushBuffer() |
|
10 |
void reset() |
|
11 |
void resetBuffer() |
|
12 |
void sendError(int sc) |
|
13 |
void sendError(int sc, String msg) |
|
14 |
void sendRedirect(String location) |
|
15 |
void setBufferSize(int size) |
|
16 |
void setCharacterEncoding(String charset) |
|
17 |
void setContentLength(int len) |
|
18 |
void setContentType(String type) |
|
19 |
void setDateHeader(String name, long date) |
|
20 |
void setHeader(String name, String value) |
|
21 |
void setIntHeader(String name, int value) |
|
22 |
void setLocale(Locale loc) |
|
23 |
void setStatus(int sc) |