I've been at this for the better half of a day already 
without joy.  Am trying to create a Filter which accepts
a request for "/fr/Products/Toys/index.jsp" and forwards 
the request to "/Products/Toys/index.jsp" after setting
an attribute "lang" to "fr".  

However, no matter what I try, the following error is 
produced: "java.lang.IncompatibleClassChangeError".
I have tested the URL "/Products/Toys/index.jsp" directly
in a browser and there is no problem with it, and using
System.out.println calls, I have deduced that the error
lies in the rd.forward(request, response) line. 

Does anybody have any idea why this may be happening?
I'm using Tomcat4.0 


Filter Source Code
------------------

public final class LanguageFilter implements Filter {

private FilterConfig filterConfig = null;
 
public void init(FilterConfig filterConfig) {
   this.filterConfig = filterConfig;
}

public void doFilter(ServletRequest request, ServletResponse response, FilterChain 
chain) throws IOException, ServletException {
    String servletPath = ((HttpServletRequest) request).getServletPath();
    // If path starts with "/fr/", set the lang to "fr".
    if (servletPath.indexOf("/fr/") == 0) {
    request.setAttribute("lang", "fr");
    String targetURL = servletPath.substring(3);
    System.out.println("targetURL = " + targetURL);
    RequestDispatcher rd = null;
    ServletContext sc = this.filterConfig.getServletContext();
    rd = sc.getRequestDispatcher(targetURL);
    System.out.println("ok, RequestDispatcher created");
    if (rd!=null) {
        rd.forward(request, response);
        return;
    } 
    chain.doFilter(request, response);
}

 

Error Trace
-----------

java.lang.IncompatibleClassChangeError
at mas.TestFilter.doFilter(Store/LanguageFilter.java:35)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

Thank you for helping,

Stephen.




---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

Reply via email to