File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servlet method override" Watch "servlet method override" New topic

servlet method override

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 331

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]
I agree. Here's the link:
subject: servlet method override
It's not a secret anymore!