wood burning stoves 2.0*
The moose likes Servlets and the fly likes Filter Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Filter Problem" Watch "Filter Problem" New topic
Author

Filter Problem

shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Hi Guys

I am playing around with a filter and am having problems getting it to work. Whenever I try to reload the app in tomcat manager, it stops running. As soon as I remove the filter stuff from the web.xml it starts to run again. See code below:


Servlet:


web.xml
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Your filter is never allowing the chain to continue. See the Javadoc for the filter class.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Ok, I have updated the following:



Not sure if thats what you meant but I compiled and tried to reload the project but it still doesn't run.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Define "doesn't run".
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You might find it useful to look at the examples here:

http://java.sun.com/products/servlet/Filters.html
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Thanks for the link Paul, a good read.

I have another problem, I am trying to use response.setError() but compiler tells me 'symbol cannot be found'. It looks like its due to the fact that ServletResponse is being used and sendError works with HttpServletResponse. Is there anyway I can fix this ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Cast it.
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Thanks bear. Is there anyway I can determine the source of the filter initialisation ? So if I refreshed index.jsp is there anyway the filter can tell me it was that file that triggered it ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The request is available to the filter from which it can gather any information it would like.
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Do you have example code I could go through ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

What info are you after? have you perused that JavaDoc for the request class?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Filter Problem
 
Similar Threads
Servlet Filter problems
JSP Filter with Struts
custom tag help
Filter being called for Struts' forwarded JSP
User filter