• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you set a servlet context attribute?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using Tomcat 6.0.26. I have this in my web.xml file ...



But in my servlet, this call returns null ...



So my question is, what is the right way to set an attribute of a servlet context?

Thanks, - Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrong method. Check the API again.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Come on, man, I need a little bit more than that. What is the "wrong method"?
 
Poobhathy Kannan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you should have used ServletContext#getInitParameter method
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Alvarado wrote:Come on, man, I need a little bit more than that. What is the "wrong method"?

Learning to read the Javadoc is an important skill.
 
Elchin Asgarli
Ranch Hand
Posts: 222
Chrome Eclipse IDE Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Dave Alvarado wrote:Come on, man, I need a little bit more than that. What is the "wrong method"?

Learning to read the Javadoc is an important skill.


And what about this? http://faq.javaranch.com/java/BeNice
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is not nice about teaching people something?
 
Madhawi Maurya
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you should write like


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic