• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Generic Servlet & ServletContext

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a doubt.
Generic Servlet & ServletContext both contain a log() method.
I read in the Servlet docs that


GenericServlet also implements the log method, declared in the ServletContext interface.


But Generic Servlet implements Servlet & ServletConfig interfaces.. so how can it implement a ServletContext's interface method. or is Generic Servlet defined a new method of its own..

If yes, what is the purpose of defining it in both GenericServlet & ServletContext, since you can obtain a servletcontext object from your generic servlet.

I know I am missing something here , please clarify.
Thanks in advance
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say the wording in the javadocs is a bit misleading. It should probably read something like "GenericServlet also implements the log method, which has the same semantics as the log method declared in the ServletContext interface."

Strictly speaking, you're right that the method is different from the one in ServletContext.
 
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
Note that the description has been replaced in Servlets 2.5 :

Before:
GenericServlet makes writing servlets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface.

After:
GenericServlet makes writing servlets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet also implements the log method, declared in the ServletContext interface.

The javadoc does not seem to be updated though...
[ March 18, 2008: Message edited by: Christophe Verre ]
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

1. GenericServlet does not implements ServletContext.

2. The log() method in Generic Servlet implements ServletContext log() method just by calling getServletContext().log()

If yes, what is the purpose of defining it in both GenericServlet & ServletContext, since you can obtain a servletcontext object from your generic servlet.



You may want to override it. This is what my understanding. Please correct me if I am wrong.
 
Khadija Lokhandwala
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe,

The javadoc is unchanged. But I can not figure out the methods repeated in GenericServlet & ServletContext.

Ashok had quoted



The log() method in Generic Servlet implements ServletContext log() method just by calling getServletContext().log()




that's what i think too..
Any inputs???
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic