On Fri, 28 Dec 2001, Yoav Shapira wrote:

> Date: Fri, 28 Dec 2001 15:37:23 -0500
> From: Yoav Shapira <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Filter mapping question
>
> Hi,
> I have a servlet and a filter I want to be run when that servlet
> is accessed.  However, the servlet is never accessed directly via
> the browser.  Rather, it's embedded in a frameset and launched
> using something like this:
> <a href="javascript:void(0);"
>    onClick="thatframe.src='http://myhost/mycontext/myservlet'; return
> true;">
> click here
> </a>
>
> So in my web.xml, I have:
> <filter>
>   <filter-name>myFilter</filter-name>
>   <filter-class>myFilterClass</filter-class>
> </filter-name>
>
> <filter-mapping>
>   <filter-name>myFilter</filter-name>
>   <servlet-name>myServlet</servlet-name>
> </filter-mapping>
>
> <servlet>
>   <servlet-name>myServlet</servlet-name>
>   <servlet-class>myServletClass</servlet-class>
> </servlet>
>

I assume you also have a servlet mapping, right?  It would need to look
like this:

  <servlet-mapping>
    <servlet-name>myServlet</servlet-name>
    <url-pattern>/myservlet</url-pattern>
  </servlet-mapping>

> The problem is, tomcat never calls doFilter() for my filter when that
> servlet is called.  The filter gets initialized appropriately (I have
> logging comments on the filter's init(), doFilter(), destroy() methods).
>
> If I go to http://myhost/mycontext/myservlet myself, the filter does
> get called, so I know it has to do with the calling mechanism,
> filter-mapping,
> or something along these lines.
>
> Thanks in advance, and sorry for the long post,
>

Tomcat has no way to know whether the request came from the location line
of the browser or via JavaScript -- so that's not the cause of the
problem.  You can look at the access log (in the "logs" directory) to see
what URI is really being requested when you do it manually, and when the
Javascript function calls it, to ensure that they are really identical.

One other thing to check is that your servlet mapping is really for
"/myservlet" and not for "/myServlet".  URLs are case sensitive, so this
would cause a mismatch.

> Yoav Shapira
> Millennium Pharmaceuticals, Inc.
> [EMAIL PROTECTED]
>

Craig McClanahan


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to