The moose likes Servlets and the fly likes Cannot find servlet init parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot find servlet init parameters" Watch "Cannot find servlet init parameters" New topic

Cannot find servlet init parameters

Toby Davis
Ranch Hand

Joined: Apr 09, 2002
Posts: 65
I'm trying to grab initialization parameters for my servlet, based on params established in my deployment descriptor. Yet my servlet can't find any of them (returns nulls).
This is in my deployment descriptor snippet for a particular servlet:

Yet, in my servlet, it cannot read any of the initialization parameters (in the init() method of MyServletController snippet below):

The above code snippet would return strParam as null. In fact, no matter what's in the deployment descriptor for this servlet, no initialization parameters can be found. I know the web.xml is deployed properly, otherwise this servlet could not be invoked in the first place.
Something I'm missing that's simple I hope?
[ June 05, 2002: Message edited by: Toby Davis ]

SCJP2 (1.4)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Pretty odd alright. Just for fun try working with the config object directly.

The other thing you might try is to rearrange the order of elements in web.xml - the Sun examples always put servlet-class right after servlet-name, and then put init-param elements so thats the way I have always done it.
I agree. Here's the link:
subject: Cannot find servlet init parameters
It's not a secret anymore!