struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: Dynamically rendering image - Servlet/Action
Date Mon, 02 Jul 2007 14:49:34 GMT
On 7/1/07, Stjepan Brbot <stjepan.brbot@zg.t-com.hr> wrote:
> Hi,
>
> I have one classic HttpServlet for dynamically rendering an image from given
> (database retrieved) data. Actually this servlet takes data from session
> (previously retrieved from database and put inside session) and renders the
> image. Since this is not Action but classis servlet it is mapped in web.xml
> as '/ImageServlet'. When I have in my html/jsp tag like this one '<img
> src="/ImageServlet">', I get wanted image. That's all fine.
>
> Now, I'd like to avoid using session for this purpose and like to take data
> for ImageServlet from request but I see that request data is not forwarded
> in additional browser's request for image. When I originally request page
> like 'page.jsp?id=1' this 'id=1' is not forwarded in request for image data
> '<img src="/ImageServlet">' from page.jsp! That's why I use session. Is this
> only possibility? Can I use '<html:img src=.../>' or '<html:img action=...>'
> and expect original page request to be forwarded to image request as well?
>
> On the other hand, how to create Struts' Action that could be used for the
> same purpose of rendering image? In classic HttpServlet there are methods
> doPost/doGet which do not return any data (void) but Struts' Action expects
> ActionForward as a return value. What might be the return value in case that
> this Action is used for rendering image and called inside '<img
> src="/ImageAction">' or '<html:img action="/ImageAction"/>'?

There is just such a DownLoad action designed to help with this - you
just need to return "null" from the Action's execute method, rather
than an ActionForward:

http://wiki.apache.org/struts/StrutsFileDownload
http://struts.apache.org/1.3.8/apidocs/org/apache/struts/actions/DownloadAction.html

Niall

> SB

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message