aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes servletcontext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "servletcontext" Watch "servletcontext" New topic
Author

servletcontext

Neeraja Neeraj
Greenhorn

Joined: May 11, 2003
Posts: 29
can anybody pls let me know the difference between the methods:
1.getServletContext()
2.getServletConfig().getServletContext()
How does the ServletContext returned by these two methods differ?
Thanks
Neeraj
Jason Qiu
Greenhorn

Joined: May 20, 2003
Posts: 13
can anybody pls let me know the difference between the methods:
1.getServletContext()
2.getServletConfig().getServletContext()
How does the ServletContext returned by these two methods differ?
There is no any difference!
Acctually, they are the same method.
Please note that the GenericServlet implements the ServletConfig interface as well as Servlet interface. And all HttpServlets are children of GenericServlet.
getServletContext() is defined in ServletConfig interface and is implemented in GenericServlet.
So you can use either the getServletContext() of HttpServlet or use the getServletContext() of the ServletConfig.
They are absolutely the same!
Andres Bonifacio
Greenhorn

Joined: May 16, 2003
Posts: 19
This is additional info. Look at the source code of GenericServlet. The method getServletContext() encapsulate calls to getServletConfig().getServletContext()


<a href="http://weblog.homelinux.com/blojsom/blog/" target="_blank" rel="nofollow">http://weblog.homelinux.com/blojsom/blog/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servletcontext
 
Similar Threads
servletContext
HFS p825 Q49
getServlet().getServletContext();
ServletContext Vs ServletConfig
Obtain ServletContext from Request