• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Servlet Context and Servlet

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am a bit confused regarding who is created first ,a servlet ,or a servlet context?
According to my logic ,servlet context must be created first.
Please correct me if I am wrong.


Thanks and regards.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
servletContext(is required for) --> servletConfig(is required for) --> Servlet Initialization
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Pravin,
So may i conclue that the servlet is created after the servlet context has been created,and hence a listener class(ContextLoaderListener) will run before a servlet(DispatcherServlet)?

Thanks.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ContextLoaderListener is a Spring class and has nothing to do with Servlets when Spring isn't being used.

If you mean ServletContextListener, then yes, this listener's contextInitialized() method will fire before any servlets are loaded or requests are processed.
 
Sheriff
Posts: 28395
100
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you think of the servlet context as representing the whole web application, the answer becomes obvious, doesn't it?
 
pravin venkat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sudhanshu Mishra wrote:Thanks Pravin,
So may i conclue that the servlet is created after the servlet context has been created,and hence a listener class(ContextLoaderListener) will run before a servlet(DispatcherServlet)?

Thanks.



Yes
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic