Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

servlet context and servlet config  RSS feed

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm a beginner, learning servlets. Could anyone please explain clearly what a servletContext and servletConfig does?


Thanks,
d86
 
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"d86", please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the JavaDoc for these classes?
 
divya anand
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



no. i use head first book, but the explanation given for it was not clear to me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66789
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

divya anand wrote:no.


Then it's time to read them.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see Divya....head first book is very good...and moreover its clearly written there that servlet context is for the whole web application while servlet config is for a particular servlet. Particular servlet means the servlet you had written for your web application and whose entry is there in the deployment descriptor. You can access the init parameter(deploy time constant parameters) from the servlet context and servlet config object. There are lot many concept...but for that you need to study..... but this is what i can say in nutshell....
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You see it is very Simple.

ServletConfig is basically used for configuring individual servlet. Si in a nut shell it is used for servlet specific

configuration. That is why you write <init-param> inside the <servlet>tag.It's specific to individual servlet.


ServletContext is more of a Global object.It is global to application object. If you want object to be shared by all

instances (actually thread) of servlets that run in an application you write it in ServletContext. That is why you write

<context-param> tag inside <web-app> tag. Not inside <servlet> in DD.

I hope it has solved the problem.

Read Head First. It's clearly mentioned.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!