tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi Sharma <>
Subject Re: Filtering URL via tomcat
Date Fri, 01 May 2009 23:36:23 GMT
Hi All,
I guess i did not explained it properly. Let me try once again in simple
way. Forget about what i wrote before.

my Webapps dir have one application called app and has following dir


above dir contacins html pages which are being generated by tomcat whenever

someone can request these files with url like

I wanted to server these pages only to registered user of my site so i put
one filter in web.xml of my application

So whenever someone try to access this url and if he is not logged in
Filter forwars the request to login page(this part is working fine, Filter
seems working fine).
Now if user is logged in then i dont do any redirection to login page in
Filter class. Class code as follows

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

        HttpServletRequest httpRequest = (HttpServletRequest)request;
        HttpServletResponse httpResponse = (HttpServletResponse)response;
       doBeforeProcessing(request, response); // No code in this function
        String accessedUrl = httpRequest.getRequestURI();
        String targetUrl = httpRequest.getRequestURL().toString();

    Throwable problem = null;

        //chain.doFilter(request, response);
        catch(UserNotLoggedIn ex)
            httpResponse.sendRedirect(httpRequest.getContextPath() +
LOGINURL +"?URL=" + targetUrl);
        catch(OperationNotAllowedForUser ex)
            httpResponse.sendRedirect(httpRequest.getContextPath() +
        catch (ApplicationException ex)

        chain.doFilter(request, response);

    doAfterProcessing(request, response); // No code in this function

    if (problem != null) {
        if (problem instanceof ServletException) throw
        if (problem instanceof IOException) throw (IOException)problem;
        sendProcessingError(problem, response);

Problem : Now when user is logged in then user should be able to see this
page content of

but on this page in browser user getting following tomcat error

*Type* Status report
*message* */app/audio/download/abc.html
**description* *The requested resource (/app/audio/download/abc.html) is not

But the file do exists in this location.
Any idea why it is happening?


On Fri, May 1, 2009 at 5:19 PM, Christopher Schultz <> wrote:

> Hash: SHA1
> Ravi,
> Some things aren't adding up:
> > (anyone/guests can see this page)
> > (only logged in user
> can
> > see this page)
> ...and...
> > the root of my site reside in appache httpd server
> > so i have folder structure like
> > mysite/public_html/audio
> > mysite/public_html/app/audio/download
> >
> > in my httpd conf i have something like this
> > JkMount /app/audio/download/* ajp13w
> You have JkMounted /app/audio/download but your URLs above suggest this
> should be /audio/app/download/abc.html. That's strange.
> You have your webapp in a directory called "mysite" but the context name
> is "app". That's strange.
> On 4/27/2009 2:26 PM, Ravi Sharma wrote:
> > is a html being served by httpd
> > correctly
> > then when i try to access
> > get following error
> > on browser
> >
> > *Type* Status report
> > *message* */app/audio/download/abc.html
> > **description* *The requested resource (/app/audio/download/abc.html) is
> not
> > available.**
> Sounds like this is a Tomcat error. Are you attempting to serve
> /app/audio/download/abc.html from within Tomcat? If so, is that file
> (abc.html) actually deployed as part of the web application?
> I think it would be helpful to post more of your httpd configuration and
> the output of 'find' in your webapp's root directory.
> Another question: why are you implementing your own authentication and
> authorization instead of using those built-in features of Tomcat? Seems
> like re-inventing the wheel...
> > There are no errors in catalina.out(and this is the only file in logs dir
> of
> > Tomcat)
> catalina.out will not contain errors like "file not found". If you want
> to see what requests are being served, you'll want to enable the
> AccessLogValve. See
> for details.
> - -chris
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla -
> 1HsAn11gsfaTF1DxL9xd3/QMRiVaqhFH
> =aPN/
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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