File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Init / Context Parameters revisted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Init / Context Parameters revisted" Watch "Init / Context Parameters revisted" New topic

Init / Context Parameters revisted

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695


I see where this has been gone over in other posts, but I'm having a bit of trouble with something and thought maybe someone could tell me why something doesn't work.

What I used to have was this:
If you look at the third entry in this thread, you'll see that i used initialization parameters, then obtained a servlet context, and placed each of these init params into the servlet context.

Then I was told, (later in the thread) that I was doing something the hard way.

So here is what I have now, except it's not working... Can someone tell me why?

servlet code:This code throw a servletException, because the value of my envSTRINGS are null. How come?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I have answered my own question. There were two things wrong. I was using getAttribute, but I should have still used getInitParameter.

Secondly, as my comments enlighten me (because I'll forget 6 months from now why I did something seemly silly), the context attributes are different than the parameters.
I agree. Here's the link:
subject: Init / Context Parameters revisted
It's not a secret anymore!