This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Application Frameworks and the fly likes Why is this piece of code required from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Why is this piece of code required from a servlet" Watch "Why is this piece of code required from a servlet" New topic
Author

Why is this piece of code required from a servlet

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hai , i have see a lot of codings in which this piece of code is always present.

ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());


Please tell me what is the use of this one .


Save India From Corruption - Anna Hazare.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You need it if you want to get the ApplicationContext from a servlet. Suppose you want to get a bean "myBean" from a servlet, then you need to do this.


Hope this helps.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you ver much Freddy (Federer )
 
wood burning stoves
 
subject: Why is this piece of code required from a servlet