Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IOException in the signature of doGet and doPost methods ??  RSS feed

 
Bikash Paul
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any please tell me why by default IOException is present in the signature of doGet and doPost method of servlet.

Thanks & Regards
Bikash
[ May 19, 2004: Message edited by: Bikash Paul ]
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would assume because the interface HttpServletResponse which extends ServletResponse lets you for example specify outgoing information such as HTTP status codes(202, 404 etc), response headers(Content-Type, Set-Cookie etc)and probably most importantly lets you obtain a PrintWriter, which is used to send document content back to the client.



Craig.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before the Model 2 pattern came into vogue, it was customary for the servlets to produce the output for the response (as opposed to forwarding to a JSP page). Even within this pattern, there are many occasions when the servlet must create output (for example, binary data for which JSPs are unsuitable).

As such, there are common scenarios where IO exceptions will occur. And rather than having to wrap them in a ServletException, the authors of the servlet specification allowed the IO exceptions to be thrown directly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!