Hi

When you say that I should use an action and "write the bytes in the 
perform method" I am not quite sure I follow.  I have only returned an 
ActionForward object from the perform() method in an Action class.  So 
how do I make it return a byte string representing the image?, should I 
write another perform() method?

Cheers

Antony


> in the JSP you write an image tag like 
> ---------------------------------------------------------
> <img src="<html:rewrite page="/servlet/ImageServlet" 
> paramId="id" paramName="imageBean" paramProperty="id">
> ---------------------------------------------------------
> this hopefully renders to 
>       <img src="/servlet/ImageServlet?id=1234432">
> 
> This will cause an extra http request to the mapped servlet. 
> 
> In the servlet you should do something like:
> ---------------------------------------------------------
> response.setContentType("image/gif");
> response.setContentLength(imageBean.getLength());
> response.setHeader("Content-disposition","attachement;
> filename="+imageBean.getFilename());
> ServletOutputStream stream = response.getOutputStream();
> //copy dbstream to servletOutputStream
> stream.write(imageBytes);
> ---------------------------------------------------------
> Instead of the servlet you could probably use an action
>       <img src="/ImageAction.do?id=1234432">
> and write the bytes in the perform method, but I did not test this one.

>>
>>>Hi
>>>
>>>I need to retrieve pictures from a database and use struts to display
>>>them.   I am not sure about the best way to do this.  Can someone please
>>>tell me how they do it and what they beleive the best approach is.
>>>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to