File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How do you set a servlet context attribute? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How do you set a servlet context attribute?" Watch "How do you set a servlet context attribute?" New topic
Author

How do you set a servlet context attribute?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
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

Joined: Jan 10, 2002
Posts: 61008
    
  65

Wrong method. Check the API again.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Come on, man, I need a little bit more than that. What is the "wrong method"?
Poobhathy Kannan
Ranch Hand

Joined: May 26, 2004
Posts: 94
i think you should have used ServletContext#getInitParameter method


http://learnertobeginner.blogspot.com/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

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

Joined: Mar 08, 2010
Posts: 222

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


Personal page, SCJP 6 with 91%, SCWCD 5 with 84%, OCMJD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61008
    
  65

What is not nice about teaching people something?
Madhawi Maurya
Ranch Hand

Joined: Aug 22, 2007
Posts: 42
Hi,

you should write like



SCJP1.5 with 90%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you set a servlet context attribute?