Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Init / Context Parameters revisted

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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: http://www.javaranch.com/ubb/Forum7/HTML/000638.html
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?

web.xml
servlet code:This code throw a servletException, because the value of my envSTRINGS are null. How come?
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic