Hi I hope I can use wicket to serve image data. I know I can extend org.apache.wicket.markup.html.image.Image and provide a DynamicImageResource but the generated image link is http://localhost/app/?wicket:interface=:0:customImage::IResourceListener:: The image data is stored in the session and not bookmarkable, which is not what I want.
I then created an ImagePage extends WebPage and override onBeforeRender() , and coding below : HttpServletResponse response = ((WebResponse) getWebRequestCycle().getResponse()).getHttpServletResponse(); try { response.setContentType("image/png"); OutputStream responseOutputStream = response.getOutputStream(); responseOutputStream.write(myImageBytes); responseOutputStream.flush(); responseOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } It works !!! And I can bookmark the image. But there are warning output : 2008-12-26 02:20:42,919 ERROR wicket.RequestCycle - org.apache.wicket.Component has not been properly rendered. Something in the hierarchy of foo.bar.ImagePage has not called super.onBeforeRender() in the override of onBeforeRender() method java.lang.IllegalStateException: org.apache.wicket.Component has not been properly rendered. Something in the hierarchy of foo.bar.ImagePage has not called super.onBeforeRender() in the override of onBeforeRender() method at org.apache.wicket.Component.internalBeforeRender(Component.java:1006) at org.apache.wicket.Component.beforeRender(Component.java:1034) at org.apache.wicket.Component.prepareForRender(Component.java:2160) Is this the "standard" way of outputing binary data ? If not , what is the better way (wicket 1.3.5) ? thanks.