Implicit Objects in JSP, Response Implicit Object in JSP, How send back response to the client in JSP
response is an object of HttpServletResponse Interface, It is used to send back the response to the client according to the query fired by the user. The HttpServletResponse interface has the number of methods to do the different kind of tasks like sending the response to the user, redirecting the page from one JSP to another JSP page, sending cookies information to the client, setting the content length and content type to the response page, sending the error to the client, printing the string to the client browser etc.
The most usable methods of response object are as follows-
1. setContentLength(int length):- It is used to set the length of the content which is sending to the client as a response by the server.
2. setContentType(String contenttype):- It is used to set the content type which will be displayed on the client browser as a response of the query of the user.
2. sendRedirect(String nextPageURL):- It is used to redirect the control from one page to another JSP page.
4. addCookie(Cookie c):- It is used to add the Cookies to the response object which are used to maintain the state of a user.
5. reset():- It is used to reset the response object as a new object.
6. sendError(int statusCode):- It is used to send the error code to the client if there is any error found by the server into the application. The numeric code need to be passed into it.
7. sendError(int statusCode, String errMessage):- It is also do the same task as above we have discussed but, this method has the another parameter in it eg. String errMessage, it is used to send the error message with the status code .
8. setStatus(int statusCode):- it is used to set the status to the browser.
response is an object of HttpServletResponse Interface, It is used to send back the response to the client according to the query fired by the user. The HttpServletResponse interface has the number of methods to do the different kind of tasks like sending the response to the user, redirecting the page from one JSP to another JSP page, sending cookies information to the client, setting the content length and content type to the response page, sending the error to the client, printing the string to the client browser etc.
The most usable methods of response object are as follows-
1. setContentLength(int length):- It is used to set the length of the content which is sending to the client as a response by the server.
2. setContentType(String contenttype):- It is used to set the content type which will be displayed on the client browser as a response of the query of the user.
2. sendRedirect(String nextPageURL):- It is used to redirect the control from one page to another JSP page.
4. addCookie(Cookie c):- It is used to add the Cookies to the response object which are used to maintain the state of a user.
5. reset():- It is used to reset the response object as a new object.
6. sendError(int statusCode):- It is used to send the error code to the client if there is any error found by the server into the application. The numeric code need to be passed into it.
7. sendError(int statusCode, String errMessage):- It is also do the same task as above we have discussed but, this method has the another parameter in it eg. String errMessage, it is used to send the error message with the status code .
8. setStatus(int statusCode):- it is used to set the status to the browser.
{ 0 comments... read them below or add one }
Post a Comment