tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roberto <>
Subject Images & CSS not loaded after the request passes through a Servlet Filter
Date Thu, 28 Apr 2005 17:25:07 GMT

I have a small java application, in which a servlet processes the request 
and then
calls a JSP to present the data. Everything is OK with that configuration. 
Then, I decided
to create a servlet filter, to redirect every request to that application, 
to a login page first.

The code of that filter is the following:

public final class ApplicationFilter implements Filter {
private FilterConfig _fc = null;

public void init(FilterConfig filterConfig)
throws ServletException {
this._fc = filterConfig;

public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException,
ServletException {

try {
RequestDispatcher rd = 
rd.forward(request, response);
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());

-- (the rest was intentionally omitted) --

The redirection works great, BUT all images and CSS referenced in the JSP 
file are not
loaded after the request passes through the filter. The application runs 
perfectly, and takes
the user to the login screen, and after that, to the application. The 
application does some
database queries and returns the data correctly. BUT, everything without 
images or the
styles defined in the CSS file. 

Just to make a test, I put the CSS file contents directly inside the JSP 
file, and it
worked great. In this case, images were not loaded also...

The process flows like this:

Request --> Filter --> login (a servlet) --> login.jsp --> queryDB (a 
servlet) --> queryDB.jsp

When I disable the filter, in the web.xml file, everything works as would be 

The configuration in web.xml is OK: all servlets are set, as is the filter 

I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and 
2.6.9. The hardware is a P IV HT 3.2 Ghz.

I also checked the archives of this list, but was unable to find any 
reference to a problem
like this one. Does anyone know what is happening ?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message