tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Curwen" <mi...@gb-im.com>
Subject Filters and 4.1.24
Date Tue, 17 Jun 2003 14:05:39 GMT
I've tried searching nagoya and the tomcat-user archive, though I'm
notoriously bad at choosing keywords. So I apologize if this has come up
hundreds of times before.
 
I was working through an example of Filtering from WROX's Professional
JSP 2nd Edition.  Chapter 15 shows us how to create a Filter that uses
wrapped response objects to include a footer at the bottom of every
page. 
 
I just could *not* get the pre-compiled code to work, so I inserted my
own debugging statements using log4j and let it run.. it seemed my
single request invoked the filter between 1 and 3 times, apparently
without pattern.  what was happening was it would start to output the
footer, but stop after the first word. I changed this word, and did
other logging changes as a sanity check. My logging changes were
visible, but that old word (now nowhere in code) was still getting
output.  Restarted the container, restarted the OS (WinXP).. couldn't
get it to work!
 
Then I read the following from the book: "At this point, some readers
may question the necessity to test all 3 types of resources (static
HTML, JSP and Servlet). However, if you're creating filters that must
work across many types of resources, you *must* test against each type
of resource. The is necessary because of type of resource is passed
through a different resource processor, each of which potentially has
different assumptions and behaviours..."
 
Now what I had been doing up to that point is:
http://localhost:8080/wrox/

So that was a static resource I was requesting.. index.html  And yah,
maybe that filter might get poked multiple times, once for the / request
and once for the actual (internally determined) request for index.html
and perhaps a final time when the static loader was invoked.
 
So I tried to request:
http://localhost:8080/wrox/jsp

This produced a nice directory listing, at the bottom of which had my
inserted footer, as expected. This is the directory listing resource
processor.

http://localhost:8080/wrox/jsp/findProd.jsp

Produced a blank screen. Logging indicated that the filter received
'null' as the response input. So the Filter doesn't work through the JSP
processor.

At that point I gave up on the wrox app, and moved the filter over to
the application I actually needed it for, and tried to invoke a few
servlet resources. 

http://localhost:8080/myapp/myservlet

This worked as expected. So the Filter worked with servlets.

My results:

static resources  ->  X (very odd behaviour, output from seemingly
nowhere)
JSP               ->  X (couldn't find the JSP to invoke)
Servlet           ->  Y (worked as expected)
Directory Listing ->  Y (worked as expected)

Has anyone else had issues with Filters and these various combinations ?

-------------------------------------------
Mike Curwen                    
Intermediate Programmer       www.gb-im.com
-------------------------------------------
  ____   ____            ___   __  __ 
 / ___| | __ )          |_ _| |  \/  |
| |  _  |  _ \   _____   | |  | |\/| |
| |_| | | |_) | |_____|  | |  | |  | |
 \____| |____/          |___| |_|  |_|


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message