• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filter life cycle

 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've written the following code and my problem is that I'm not getting the message from the init() method of the filter. Rest all is displayed. Why is it so? Isn't the call to init() is the first thing container does when it sees a filter?



Asha
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but it would only be called once; when the filter is put into service.

Did you try restarting your app?
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I've tried restarting the server but that doesn't help at all.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried it and it worked fine for me.


What container are you using?
 
Asha Pathik
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Tomcat and I would like to ask one more thing. In your replay the "Filter Destroyed" message is coming before "Filter Initialized". Why is it happening like that?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Filter Destroyed is showing first because I was using the Tomcat manager to restart the app. Every time I restart it the destroyed method gets called, the app shuts down, then the app starts up and the initialized method is called.


As to why you're not seeing the messages....
It's been a while since I've used System.out.println in a webapp but I do remember, a while back, with a different version of Tomcat, seeing println statements in some servlet init methods being written to a different log file than println statements in the service methods.

Check all the log files under tomcat/logs to see if they are being written somewhere else.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!