File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Filter Problem

 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your filter is never allowing the chain to continue. See the Javadoc for the filter class.
 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define "doesn't run".
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find it useful to look at the examples here:

http://java.sun.com/products/servlet/Filters.html
 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cast it.
 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request is available to the filter from which it can gather any information it would like.
 
shaf maff
Ranch Hand
Posts: 180
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have example code I could go through ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What info are you after? have you perused that JavaDoc for the request class?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic