• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

getting reference to the servletContext

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if genericServlet class implement servlet interface every servlet implicitily have servletContext methods.
then why we need to get reference to the using getServletContext() method ?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
GenericServlet class implements Servlet, ServletConfig and Serialisable interfaces only.

ServletContext is altogether a different interface, which is not implemented by Servlet, GenericServlet or HttpServlet.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:if genericServlet class implement servlet interface every servlet implicitily have servletContext methods.



Which method(s) are you talking about in Servlet interface?
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:if genericServlet class implement servlet interface every servlet implicitily have servletContext methods.



By the way Servlet interface doesnt have getServletContext(). ServletConfig has the getServletContext() and GenericServlet gives the implementation which is Super class of HttpServlet . look Here.

So you can do like below in your servlet



this what you want to know?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

aruna sameera wrote:if genericServlet class implement servlet interface every servlet implicitily have servletContext methods.



By the way Servlet interface doesnt have getServletContext(). ServletConfig has the getServletContext() and GenericServlet gives the implementation which is Super class of HttpServlet . look Here.

So you can do like below in your servlet



this what you want to know?
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic