my dog learned polymorphism
The moose likes Servlets and the fly likes ServletContext Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContext Doubt" Watch "ServletContext Doubt" New topic

ServletContext Doubt

siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59

What does this statement do and what is the use of ServletContext i know context information shared by multiple servlets but the following code i cant able to understand
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi siva,

this refers to the current object and getServletContext() Returns a reference to the ServletContext in which this servlet is running.

There is one context per "web application" per Java Virtual Machine

So it will return the context of current object.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

----> this refers implicit parameter . you dont require to specify in general.

you cant do (1) as well as (2) .
I agree. Here's the link:
subject: ServletContext Doubt
It's not a secret anymore!