you cant do it like that
look at ResourceStreamRequestTarget

what you want is a combination of that and AbstractRestartResponseException
so you must set the RequestTarget in the RequestCycle and then throw an
AbstractRestartResponseException
(just like RestartResponseException works)

johan


On Thu, Feb 26, 2009 at 10:45, freak182 <eman.noll...@gmail.com> wrote:

>
> Hello,
>
> How can i send a serialize object using byteArrayOutput stream in wicket
> page. here is my code:
>
> public class BridgeIndex extends WebPage {
>
>  public BridgeIndex()
>    {
>        final HttpServletResponse response =
> getWebRequestCycle().getWebResponse().getHttpServletResponse();
>        ObjectOutputStream out = null;
>
>        final ByteArrayOutputStream byteObj = new ByteArrayOutputStream();
>        final BridgeObject bObj = new BridgeObject();
>        bObj.setPassword("123456");
>        bObj.setUsername("test");
>        try
>        {
>
>            out = new ObjectOutputStream(byteObj);
>
>            log.info("Serializing the object...");
>            // serialize the object
>            out.writeObject(bObj);
>
>            response.setHeader("Cache-Control", "no-store");
>            response.setHeader("Pragma", "no-cache");
>            response.setContentType("application/octet-stream");
>            final ServletOutputStream outstream =
> response.getOutputStream();
>
>            outstream.write(byteObj.toByteArray());
>            outstream.flush();
>            outstream.close();
>
>        }
>        catch (MalformedURLException e)
>        {
>            e.printStackTrace();
>        }
>        catch (IOException e)
>        {
>            e.printStackTrace();
>        }
>
>    }
> }
> ...i get this error....
>
> ERROR - WicketFilter               - closing the buffer error
> java.lang.IllegalStateException: STREAM
>        at org.mortbay.jetty.Response.getWriter(Response.java:586)
>        at
> org.apache.wicket.protocol.http.WebResponse.write(WebResponse.java:355)
>        at
>
> org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:73)
>        at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:371)
>        at
>
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
>        at
>
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1089)
>        at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
>        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:712)
>        at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
>        at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>        at org.mortbay.jetty.Server.handle(Server.java:295)
>
> ...i want to access user object to the separate application..tnx.
>
> Thanks a lot.
> Cheers.
> --
> View this message in context:
> http://www.nabble.com/How-to-send-serialize-byteArrayOutput-stream-from-wicket-page-tp22220804p22220804.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to