This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 327

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: 163

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]
subject: servlet method override
Similar Threads
GET vs POST-Doubt
HTTP Status 405 error comes
About doGet and doPost of Services
doPost(), doGet()