I am using a servlet, in that servlet I used a doPost() method by
extending the HttpServlet. then who implement the all remaining methods( doGet,doPut,doHead,doOptions.......)

Recommended Answers

All 10 Replies

Would you be more specific in what you try to do or what you trying to say? I do not understand what you asking...

I am trying to understand the servlets concepts.
Httpservlet is an abstract class then our servlet need to implement to all the methods in that Httpservlet na?

mr. peter did u understend the my doubt?

extend your servlet with HttpServlet and then use most suitable method. No need to worry about the rest of them

Y compiler doesn't give the error ? it is an abstract class na?

No, Servlet is an abstract class, HttpServlet is not. It already has the generic implementations of the methods which the user is free to override.

No, Servlet is an abstract class, HttpServlet is not. It already has the generic implementations of the methods which the user is free to override.

r u sure? i am sure that Httpservlet and GenericServlet s are both abstract classes.by verifying kathey sierra book.

Yes, I am sorry, I got the facts wrong there. HttpServlet indeed is abstract class but the functions still have their own generic implementation. A class being abstract doesn't mean we _must_ override the functions. Such a requirement is imposed only if the functions themselves are abstract which I don't think they are. Read this.

~s.o.s~ right again :)

A subclass of HttpServlet must override at least one method

Although (at least according to the "normal" rules for class extension) it will compile just fine without overriding any of them (AFAIK, I haven't actually tried it), it just wouldn't do anything other than return the http error message that the requested http service/method is not supported/implemented.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.