i have something similar, an image servlet, rather than re write to load
from wicket, see what i did
add(new Image("imageFromServlet", new ServletImageDynamicResource());
private final class ServletImageDynamicResource extends DynamicImageResource
{
private byte[] imagegif = null;
protected byte[] getImageData() {
if (imagegif != null) {
return imagegif ;
}
imagegif = loadGIFData();
return imagegif ;
}
private final byte[] loadGIFData() {
ByteArrayOutputStream outgif = new ByteArrayOutputStream();
InputStream in = null;
try {
java.net.URL url = new java.net.URL("
http://localhost:8084/app/imgservlet");
URLConnection huc = url.openConnection();
huc.setRequestProperty("user-agent", "Mozilla(MSIE)");
in = huc.getInputStream();
int i = 0;
while((i = in.read()) != -1 )
{
outgif.write(i);
}
} catch (IOException ex) {
ex.printStackTrace();
} finally{
}
}
return outgif.toByteArray();
}
}
On 9/10/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
>
> On 9/9/07, Doug Leeper <[EMAIL PROTECTED]> wrote:
> >
> > I am looking for an example that obtains an image from the db and
> displays
> > it. Can anyone point me in the right direction? I couldn't find the
> cdApp
> > in wicket-contrib-examples
> >
> > I know that I need to use a Resource or some derivative of one, but I
> want
> > to make sure that the Image is not stored in session. I am converting
> an
> > existing JSP/Pageflow project to Wicket and have used a specific servlet
> to
> > stream the image but not sure how to do in Wicket.
>
> That cdapp example shows you how you can do that. Didn't change much
> between 1.2 and 1.3 I think.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>