• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Method of javax.servlet.Servlet

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Where menthos of interface javax.servlet.Servlet
implemented ?
i.e. getServletConfig();

If in GenericServlet then
Why it is abstract class.


Thanks in advance.
Vilas
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the methods of Servlet and ServletConfig are implemented in GenericServlet.

Only abstract method in GenericServlet is the service(ServletRequest, ServletResponse) method. The implementation of this method is left to the class which extends GenericServlet. HttpServlet happens to be one of such classes, which provides HTTP specific implementation.

Similarly we can choose to have another FTPServlet which provides FTP specific service() method implementation.

In otherwords, GenericServlet is abstract because it gives a generic signature for the service() method, leaving the implementation details to the subclass.
 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Originally posted:.............

Only abstract method in GenericServlet is the service(ServletRequest, ServletResponse) method. The implementation of this method is left to the class which extends GenericServlet.


Then,
if we don't write service method in userservelt(programmer)
& write only doGet or doPost
then how it will work.


Originallt posted:............

Similarly we can choose to have another FTPServlet which provides FTP specific service() method implementation.

What is this FTPServlet.?
[ September 17, 2007: Message edited by: Vilas Lawande ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if we don't write service method in userservelt(programmer) & write only doGet or doPost then how it will work.


If you're dealing with HTTP servlets, then you usually extend your servlet from HttpServlet, which deals with the service() method. If you extend from GenericServlet, you must implement the abstract service method, otherwise it won't compile.

What is FTPServlet


It is just an example, given by Ashwin, of another kind of class which could extend the GenericServlet. (it does not exist)
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Posted by vilas
if we don't write service method in userservelt(programmer)
& write only doGet or doPost
then how it will work.



The HttpServlet has overridden the service method which checks for the incoming request and invokes one of the method doGet,doPost.. depending on the type of request.
There is nothing stopping you from overriding the service method of HttpServlet but why do you need to do it when you have the do<Method> available?
 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot,
for valuable reply.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic