ActionForwards in Struts - design query?
"Saurabh Bobde" <[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Message-ID | <[email protected]> |
Hello.
Well - am also asking this in other forums, but thought I'd post this
Struts-related query here too.
An application team has been using a particular "style" of doing things.
In their typical Struts application, they use the Action's execute (or
similar delegate) method to process a particular request. Now, because they
do not really want to forward to another view [sounds a bit strange in
itself], instead of returning a true ActionForward (like
actionMapping.findForward{"<somefwdname">)], they do the following:
httpResponse.getWriter().write(<some data>);
return (null);
I find the "return (null)" to be a bit strange.
Now, in Struts, it works fine, because if the returned ActionForward is
null, Struts does nothing - which is what the team desires.
My question is:
A. Is this how Struts was intended to be used?
B. Is this how it *should* be used?
In my opinion, if you want to return a null ActionForward, wouldn't it then
just be better to use a standard req/resp servlet rather than an Action?
To clarify, when/why such a scenario may arise: If the request is to
retrieve a document, then imagine, a user requests for it from the view,
then the Action feteches the document from wherever, and needs to only
return a response back to the browser (client). Depending on the
content-type, the browser would leave the original view unchanged, but
possibly prompt/open up a new window to show up the requested document?
Is there an easier, elegant manner to schieve this?
Thanks,
Saurabh Bobde
~~~~~~~~~~~~~~~~~~~~~~~~~~~
"DISCLAIMER: The information contained in this e-mail message may be
privileged, confidential, and protected from disclosure. If you are not the
intended recipient, any further disclosure or use, dissemination,
distribution, or copying of this message or any attachment is strictly
prohibited. Please ensure you have adequate virus protection before you open
or detach any documents from this transmission. Zensar Technologies Inc.
does not accept any liability for virus. If you think that you have received
this e-mail message in error, please delete it and notify the sender."