• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JSP Filter with Struts

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am attempting to create a simple JSP Filter for my Struts-based application. The filter is supposed to print a line to stdout any time a JSP is accessed.

The problem I am having is that when I access my JSPs with the following filter mapping, I am not able to see the output in stdout. It's almost like the jsp is not found with the below <url-pattern>:



However, if I use a mapping like the one below, then I am able to see the output in stdout for every JSP and every other resource accessed:




My goal is find a way to only see the ouptut in stdout for JSPs and not everything else. Please advise!
Thanks!


My code:



 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out the answer to my own question. In Tomcat 4.1.31 (servlet spec 2.3), the <filter-mapping> only applies to requests (for example, from a browser). So the filters are not applied to the Struts FORWARDS.

However in Tomcat 5 (servlet spec 2.4), there is NEW support for a <dispatcher> element with FORWARD.

I am surprised that I was not able to find this answer on a search engine since it would appear to be fairly common. Anyway, for anyone interested, check out the 2.4 servlet spec on page 55 for details.

http://www.jcp.org/aboutJava/communityprocess/final/jsr154/
 
I'm doing laundry! Look how clean this tiny ad is:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic