Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Roberto
Hi,

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 = 
_fc.getServletContext().getRequestDispatcher(/login);
rd.forward(request, response);
} catch (Exception e) {
System.out.println(Exception:  + e.getMessage());
e.printStackTrace();
}
}

-- (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 
expected.

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

I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and 
kernel
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 ?

Regards,
Roberto


Re: Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Frank W. Zammetti
Question: are the requests for images and CSS files also going through the
filter?  I'm wondering if those requests are getting forarded to the logon
page too, which obviously wouldn't work.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 1:25 pm, Roberto said:
 Hi,

 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 =
 _fc.getServletContext().getRequestDispatcher(/login);
 rd.forward(request, response);
 } catch (Exception e) {
 System.out.println(Exception:  + e.getMessage());
 e.printStackTrace();
 }
 }

 -- (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
 expected.

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

 I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and
 kernel
 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 ?

 Regards,
 Roberto



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Roberto
Frank,

You got it. The filter configuration, in the web.xml file, was
intercepting ALL requests (url-pattern/*/url-pattern). I really
thought that the filter would intercept only requests for Servlets,
not all HTTP requests...

Thanks ! This problem was really pissing me off... :)

Regards
Roberto

On 4/28/05, Frank W. Zammetti [EMAIL PROTECTED] wrote:
 
 Question: are the requests for images and CSS files also going through the
 filter? I'm wondering if those requests are getting forarded to the logon
 page too, which obviously wouldn't work.
 
 --
 Frank W. Zammetti
 Founder and Chief Software Architect
 Omnytex Technologies
 http://www.omnytex.com
 
 On Thu, April 28, 2005 1:25 pm, Roberto said:
  Hi,
 
  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 =
  _fc.getServletContext().getRequestDispatcher(/login);
  rd.forward(request, response);
  } catch (Exception e) {
  System.out.println(Exception:  + e.getMessage());
  e.printStackTrace();
  }
  }
 
  -- (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
  expected.
 
  The configuration in web.xml is OK: all servlets are set, as is the 
 filter
  itself.
 
  I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and
  kernel
  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 ?
 
  Regards,
  Roberto
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]