Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting reference to the servletContext  RSS feed

 
sam liya
Ranch Hand
Posts: 1246
  • 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 ?
 
Shiraz Khan
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.
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • 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?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 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 Java Windows XP
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!