This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet method override Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet method override" Watch "servlet method override" New topic
Author

servlet method override

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 330
Hey,

Is it necessary to throw ServletException in either doGet() or doPost() in the servlet.

i mean like IOException should be throw if we take a PrintWriter out from response object.

Likewise when we need to throw ServletException?

If our method body is blank we dont need to throw none right?

Also what is this processRequest () in servlet when we use tomcat? its not there in Servlet specification right? because it says service() will called either doGet() or doPost() method not processRequest() ?

Thank You.
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 171

While overriding we may throw fewer or narrower checked exceptions or any unchecked exceptions.
So I think it is not necessary to declare that doGet() or doPost() throws ServletException and IOException.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Harshana Dias wrote:
Also what is this processRequest () in servlet when we use tomcat?


by the way processRequest is nothing to do with tomcat. i guess you are a netbeans man. it is user defined method[which is uesd in side doGet or doPost]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: servlet method override
 
It's not a secret anymore!