Hi bartlebooth.
That is very neat!
But the getImageStream method in my action is never called..
why?
bartlebooth wrote:
You could use the stream result-type.
<result name="all" type="stream">
<param name="contentType">image/jpg</param>
<param name="inputName">imageStream</param>
<param
name="contentDisposition">filename="image.jpg"</param>
<param name="bufferSize">1024</param>
</result>
In your action, you have to provide a method getImageStream
(corresponding to the inputName parameter above).
public InputStream getImageStream() {
// create a stream from your image
}
Josh Vickery wrote:
If you return null from your Action you can write directly to the
response:
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("image/jpg");
out = response.getOutputStream();
write image here
return null;
On 7/18/07, Roberto Nunnari <[EMAIL PROTECTED]> wrote:
hehe.. ok.. let's add some context..
Till now I was using a servlet to serve to the web images stored
in a database. To access the database I had the myDAO
object in the applicationContext and so it was accessible by
the servlet and actions.
Now I have added Spring to the game, and the myDAO object is
no longer in the applicationContext, as it is managed by Spring.
All my actions now extends a base class that has a setMyDAO
method, and so they get access to the myDAO object.
But what about the servlet? It will not be injected by Spring.
What is the solution?
Thank you.
Best regards.
--
Robi.
Roberto Nunnari wrote:
> Hello.
>
> What is the best way to serve images stored in database in Struts2?
>
> action, resultType, or servlet?
>
> Thank you.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]