File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Question on servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question on servlet" Watch "Question on servlet" New topic

Question on servlet

Grishma Dube
Ranch Hand

Joined: Jul 01, 2003
Posts: 275
Suppose i'm calling a servlet from jsp or html page. In that page, i'm specified method=post. But in servlet i've only doGet() and service() doPost() method. Will it throw any error or it will work fine?
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
If you override the service method and don't call the super.service(), this doesn't call the doPost() even if you request is a POST request!
if you implement only the doGet method, then you'll get an error, because the service method will try to locate a doPost() to forward the request.
Hope it helps.

Regards,<br />Andrea<br /> <br /><a href="" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID :<br /><a href="" target="_blank" rel="nofollow">My Blog</a>
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
Hi Grishma Dube
You can try this.
Add a doPost method in your servlet as follows
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletExcepion, IOException {
doGet(req, res); // calls your existing doGet method
I agree. Here's the link:
subject: Question on servlet
It's not a secret anymore!