• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet Context vs Application Context  RSS feed

 
Jyotika Kapoor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Is it true that ServletContext and ApplicationContext are one and the same thing , i thought ServletContext was unique per servlet and application context per application.


Thanks in advance
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

ServletContext and applicationContext are not same for the web application.

ServletContext per every servlet and applicationContext per web application.

So if you create one web application there is only one applicationContext in your web application.

And if you are using 5 servlet then each of your servlet contains their own ServletContext object.



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nishan Patel wrote:ServletContext and applicationContext are not same for the web application.

ServletContext per every servlet and applicationContext per web application.

Absolutely incorrect.

There is one and only one ServletContext instance per web application and it is referred to sometimes as the application context.
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is my mistake to read question and answer i wants to write ServletConfig and I write ServletContext...

It's my mistake.
 
Jyotika Kapoor
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks to both of you, i think its time for me to get back to those old books
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jyotika,

Why you go for old book....

you are right in
ServletContext and ApplicationContext are one and the same thing


But wrong in

i thought ServletContext was unique per servlet and application context per application


Not ServletContext was not unique per servlet.... But ServletConfig is unique per servlet

...

And ApplicationConext or say ServletContext are same so it is unique per web application.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!