• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlets

 
kurian chacko
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between Generic Servlet & Servlet?

A servlet is extended by HttpServlet -----> Generic Servlet ---------->Then our Servlet.
HttpServlet is needed b'coz we need to create the request & response objects of the HttpServletResponse & HttpServletRequest interfaces for which the implementation is given by the webcontainer.
They say that Generic Servlet is equivalent to Servlet.

 
Ajay Vikas
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel, Generic servlet is kept as plain Servlet becaouse, GenericServlet is for servlets that might not use HTTP, like for instance FTP servlets. Of course, there's no such thing as FTP servlets, but they may try to plan for future growth when they designed the spec. Maybe some day there will be another subclass, but for now, always use HttpServlet.

So currently we use HTTPServlet for our webservers as it supports only HTTP. In future we may come across servlets with other protocols such as FTP, LDAP, ... etc.
Hope So,

Thanks,
Ajay Vikas.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet is extended by HttpServlet -----> Generic Servlet ---------->Then our Servlet.

I think you got that the wrong way around. Your servlet extends HttpServlet, which extends GenericServlet. Strictly speaking, that all is required of your servlet is that it implements the Servlet interface. But practically, HttpServlet does some useful things that just about all servlets will need to do, so it would be silly not to extend that insteaad.

Support for FTP in servlets is highly unlikely, as are just about all other protocols. See http://faq.javaranch.com/java/ServletsFaq#10 for details.

As a hint, next time please UseAMeaningfulSubjectLine. "servlets" is way too generic to provide a clue what the question is about. And welcome to JavaRanch!
[ October 03, 2008: Message edited by: Ulf Dittmer ]
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...


YourServlet extends HttpServlet
HttpServletExtends GenericServlet
GenericServlet extends Servlet
so yourServlet dont need to implement any mehtods..all the parent interface methods were implemented..

yourServlet extends HttpServlet to get the benefit of being a web application..
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GenericServlet extends Servlet

I think you meant to say implements instead of extends.

so your servlet doesn't need to implement any methods

Of course, if it doesn't override any methods it won't be able to do much useful work :-)
[ October 03, 2008: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic