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 Problem calling setAttribute in my Filter init Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem calling setAttribute in my Filter init" Watch "Problem calling setAttribute in my Filter init" New topic
Author

Problem calling setAttribute in my Filter init

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
I have this code in my init method that attempts to set attribute in the servletContext



But anytime i run the application the Filter returns an error anytime it reaches the setAttribute




Any suggestions would be welcome
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

What is the value of tempMap at the time of the call?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
value of tempMap is some values it retrieves from the database, I was able to resolve this by getting the ServletContext using the ServletRe
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Originally posted by Abiodun Adisa:
value of tempMap is some values it retrieves from the database, I was able to resolve this by getting the ServletContext using the ServletRe


value of tempMap is some values it retrieves from the database, I was able to resolve this by getting the ServletContext using the ServletRequest of the filter

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
The difference is of course that now you're doing this every time the filter is called, instead of once at filter startup. Is that what you want/need to do?

You can get an instance of ServletContext by calling getServletContext() on the FilterConfig object that's passed to the init method.


Ping & DNS - updated with new look and Ping home screen widget
Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
Originally posted by Ulf Dittmer:
The difference is of course that now you're doing this every time the filter is called, instead of once at filter startup. Is that what you want/need to do?

You can get an instance of ServletContext by calling getServletContext() on the FilterConfig object that's passed to the init method.


Thanks for your reply, I think i would want to do this once, please how do i obtain the ServletContext in the init method
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Originally posted by Abiodun Adisa:
Thanks for your reply, I think i would want to do this once, please how do i obtain the ServletContext in the init method
He already told you in the 2nd paragraph.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem calling setAttribute in my Filter init
 
Similar Threads
error in filters
Struts 2 problem in Tomcat
Tomcat Startup Problems
Struts2 Filter Start Error in Tomcat
First Struts Application + Unable to load configuration