• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

getting reference to the servletContext

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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?
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic