This section illustrates you how to send response status in servlet.
All Response status is defined in HttpServletResponse Class. You can
then use constants (
etc..) values to return process status to the browser. In the given
example, two methods are defined doGet(), doPost. Constants value request
and response are used to return status to browser. The setContentType()
method of ServletResponse set the content type of response.
Here the Servlet requests for page name loginForm. So if the request not found, it will show error Not found. Otherwise, it will show OK.
Here is the code of SetResponseStatus.java
Above example shows how a response has been send from the servlet. If the requested page (loginForm) is not found Output will be displayed like this:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: July 17, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles