• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting servlet context in many ways

 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we can get ServletContext object in our servlet using then what is the need for getting it using the ServletConfig object i.e by
using where config refers to the ServletConfig object.
Are these methods there just for convinience ?

Regards,
Joshua.
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Based on the JavaDoc, it is only for convenience.

getServletContext

public ServletContext getServletContext()

Returns a reference to the ServletContext in which this servlet is running. See ServletConfig.getServletContext().

This method is supplied for convenience. It gets the context from the servlet's ServletConfig object.

Specified by:
getServletContext in interface ServletConfig
Returns:
ServletContext the ServletContext object passed to this servlet by the init method
 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Hendy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic