aspose file tools*
The moose likes Servlets and the fly likes servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlets" Watch "servlets" New topic
Author

servlets

kurian chacko
Greenhorn

Joined: Sep 28, 2008
Posts: 5
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

Joined: Nov 08, 2006
Posts: 66
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
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
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 ]

Ping & DNS - my free Android networking tools app
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

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..


Sudheer
SCWCD, SCJP 5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
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 ]
 
wood burning stoves
 
subject: servlets