Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servletConfig!!!

 
T Rai
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i am wondering i can servletConfig be able to carry information stored in web.xml? could you please explain me this mechanism?
thanks.
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the web.xml, under the servlet definition, you can define init parameters something like this: (I do not remember exactly, check first)

Or something like that.
Now, in your servlet's init method, you can use

to get "some value".
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Phil Chuang:
In the web.xml, under the servlet definition, you can define init parameters something like this: (I do not remember exactly, check first)

Or something like that.
Now, in your servlet's init method, you can use

to get "some value".

yes, inti-param can be defined in web.xml which can be accessed by servletConfig object. but what i am not getting here is how the servletConfig can be able to carry these information?
thanks.
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, you want the data to persist in the servlet itself?
Simple, just define some instance variables in the servlet, then set them in the init method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic