* Jan Van Besien:
> Jean-Baptiste Quenot wrote:
> > The concepts described in the static pages examples are the same
> > in 1.2.6.  You would just have to copy
> > URIRequestTargetUrlCodingStrategy in your project, it is
> > compatible with 1.2.6.
> 
> Ok, that's what I did.
> 
> In the WebPage class I have something like (StaticLink as in the example)
> 
> StaticLink fileLink = new StaticLink("fileLink", new Model("reports/" + 
> file.getAbsolutePath()));
> 
> In the WebApplication class I do
> 
> mount("/reports", new URIRequestTargetUrlCodingStrategy("/reports") {
>      public IRequestTarget decode(RequestParameters requestParameters) {
>          String path = getURI(requestParameters);
>          FileResourceStream fileStream = new FileResourceStream(new 
> File(path));
>          return new ResourceStreamRequestTarget(fileStream);
>      }
> });
> 
> Note that I use a FileResourceStream because my files are not in the 
> webapp. Now when I try to browse to a certain file, I get this in a 
> JBoss server
> 
> 08:09:44,384 ERROR [[rtApplication]] Servlet.service() for servlet 
> rtApplication threw exception
> java.lang.IllegalStateException: getOutputStream() has already been 
> called for this response
>          at 
> org.apache.catalina.connector.Response.getWriter(Response.java:596)
>          at 
> org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:186)
>          at wicket.protocol.http.WebResponse.write(WebResponse.java:315)
>          at 
> wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:75)
>          at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:229)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
>          at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>          at 
> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
>          at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>          at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>          at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>          at 
> org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
>          at 
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
>          at 
> org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
>          at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>          at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>          at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>          at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>          at 
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
>          at 
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
>          at 
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>          at 
> org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
>          at java.lang.Thread.run(Thread.java:595)
> 
> Strange thing: if I replace the 'new File(path)' with 'new 
> File("/tmp/test.txt")' it actually works (returning test.txt for every 
> link ofcourse).

If this is Wicket 1.2.6, yes I can understand this issue, and it's
fixed in 1.3.  It was a bug in BufferedWebResponse, not buffering
enough.

Back to your problem: does it work on Tomcat or Jetty?

Note that for security reasons you shouldn't mention the absolute
path in the URL.  I advise to prepend the root path in the code.
Also be careful of the double slash!  By reading your code, the
request translates to:

reports//path/to/file
-- 
     Jean-Baptiste Quenot
aka  John Banana   Qwerty
http://caraldi.com/jbq/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to