File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servlet method override Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "servlet method override" Watch "servlet method override" New topic
Author

servlet method override

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 325
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: 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]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: servlet method override
 
Similar Threads
doPost(), doGet()
GET vs POST-Doubt
HTTP Status 405 error comes
About doGet and doPost of Services
POST or GET