File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Internal functionality of getServletContext() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Internal functionality of getServletContext()" Watch "Internal functionality of getServletContext()" New topic
Author

Internal functionality of getServletContext()

NitishK Kumar
Ranch Hand

Joined: Oct 20, 2010
Posts: 40

Hi I want to know what happens when we write:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60063
    
  65

It returns the container's implementation of the ServletContext interface.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
NitishK Kumar
Ranch Hand

Joined: Oct 20, 2010
Posts: 40

Bear Bibeault wrote:It returns the container's implementation of the ServletContext interface.


I mean to ask that generally a method is invoked on an object and getServletContext() is in servletconfig interface. So, how container locates the servletconfig object.

For eg:
We write as follows



Similarly, here also it should be as . So how the container locates the servletconfig object?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39552
    
  27
Similarly, here also it should be as "servletconfig.getServletContext()"...

It actually is. "getServletContext()" is a short form of "this.getServletContext()", where "this" refers to the current object. In your example, the class extends from GenericServlet, which implements ServletConfig and has a getServletContext method.


Ping & DNS - updated with new look and Ping home screen widget
Tejas Shah
Greenhorn

Joined: Oct 26, 2009
Posts: 23

Adding some information..

And then the call passes to the container and container which takes care of the servlet context, is returned. The actual implementations may be found in container's code.


-Tejas
Cherish your life...!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internal functionality of getServletContext()
 
Similar Threads
to access the name of server
j2eecertificate mock exam question
"application" and "getServeltContext"
Confusion in code
setting attribute for the entire application