PersevereFilter, FilterChain, RequestDispatcher and forward

14 views
Skip to first unread message

SF

unread,
Jan 25, 2010, 2:50:14 PM1/25/10
to Persevere

I'd like to put an additional Filter in front of PersevereFilter to
perform simple URL-Forwarding tasks. For instance i put something like
this in a CustomFilter:

<code>
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;

RequestDispatcher rq = servletRequest.getRequestDispatcher("/Node/
14");
rq.forward(servletRequest, servletResponse);
filterChain.doFilter(servletRequest, servletResponse);
</code>

Which should forward every request to the Persevere Object "/Node/14".
The setup in web.xml looks like this:

<filter-mapping>
<filter-name>CustomFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Persevere</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

But when I try to access http://localhost:8080/abc I get a 404 error
which tells me that the RequestURI is /Node/14. The console log says:

<log>
2010-01-25 20:40:21.557::WARN: /abc
org.mozilla.javascript.EcmaError: Error: Closed
at org.mozilla.javascript.ScriptRuntime.constructError
(ScriptRuntime.java:3654)
at org.mozilla.javascript.ScriptRuntime.constructError
(ScriptRuntime.java:3632)
at org.persvr.remote.PersevereFilter$3.profilableCall
(PersevereFilter.java:392)
at org.persvr.javascript.PersevereNativeFunction.call
(PersevereNativeFunction.java:29)
at org.mozilla.javascript.NativeArray.iterativeMethod
(NativeArray.java:1581)
at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:
322)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:
129)
at org.persvr.remote.PersevereFilter.doFilter(PersevereFilter.java:
383)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
(ServletHandler.java:1115)
at org.fruehwir.persvr.SchuchardtFilter.doFilter
(SchuchardtFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
(ServletHandler.java:1115)
at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java:361)
at org.mortbay.jetty.security.SecurityHandler.handle
(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
417)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle
(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
534)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete
(HttpConnection.java:864)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:533)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:207)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
at org.mortbay.io.nio.SelectChannelEndPoint.run
(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run
(QueuedThreadPool.java:522)
</log>

What's going on here? Is this kind of setup possible or am I doing
something stupid?

Thanks,
Stefan

Kris Zyp

unread,
Jan 26, 2010, 2:24:46 PM1/26/10
to persevere...@googlegroups.com, SF

This error should occur if the output stream was already closed, but I
am not sure where in your example the stream could have been closed
prior to the persevere filter running.
Kris

SF

unread,
Jan 30, 2010, 11:43:34 AM1/30/10
to Persevere

> > org.mozilla.javascript.EcmaError: Error: Closed
>
> This error should occur if the output stream was already closed, but I
> am not sure where in your example the stream could have been closed
> prior to the persevere filter running.
> Kris

Right, that's the question. But do you have an idea what could be the
reason?

Stefan

Reply all
Reply to author
Forward
0 new messages