Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpServlet class

 
rex tony
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why HttpServlet class as Abstract?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rex,

it's simply abstract because you should extend it to create your own servlet for your application and at least override one of its service methods this way

Marco
 
rex tony
Ranch Hand
Posts: 159
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rex,

I think I indeed understood you correctly and my answer is still the same

What's the problem because HttpServlet is an abstract class? Usually you make a class abstract if you have no reasonable or just a partly default implementation and you want to define the structure of a concrete class together with the methods a concrete class should implement.

Exactly this is the case with HttpServlet. There's no reasonable implementation for the service methods like doGet(), doPost() etc. because this of course depends on what your concrete servlet in your application should do! The doGet(), doPost() and all the other methods are just declared as a skeleton for concrete servlets because these methods are expected to be called from the servlet container like Tomcat.

Perhaps I misunderstood your question so just tell what's exactly the problem for you with the class HttpServlet being abstract.

Marco
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rex,
Marco was explaining the same HttpServlet Class API.

We should write a Servlet extending this HttpServlet say LoginServlet.java.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic