Hi

Thanks for the reply. Tried it and it still gives me a NullPointer.
Maybe that's not such a problem though - since the browser still
redirects to the JSP I want. 

However, I was wondering if it's possible to use a ResourceStreamInfo to
redirect to an ActionForward (which ultimately leads to a JSP). Would
this be preferable to using RequestDispatcher.forward(request,
response)?

Richard Gundersen
Java Developer
 
Email: [EMAIL PROTECTED]
Phone: 01618302398
Fax: 01618342536
London Scottish Bank plc
24 Mount Street
Manchester
M2 3LS

-----Original Message-----
From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 01, 2007 2:47 PM
To: Struts Users Mailing List
Cc: user@struts.apache.org
Subject: Re: DownloadAction and a normal Forward

It's not the *right* answer, and I'm not sure it won't cause some other
exception anyway (in fact, I'd bet it would), but what if instead of
returning null you instead do:

return new ByteArrayStreamInfo(null, null);

?

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Wed, August 1, 2007 9:24 am, Gundersen, Richard wrote:
> Hi
>
> I'm using a DownloadAction to generate a PDF and return it the the
> browser. If there is a problem generating the PDF however, I want to
> redirect the user to a specific JSP.
>
> What's the best way of doing this? At the moment I am using
>
>
> protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm
> form,
>                                        HttpServletRequest request,
> HttpServletResponse response) {
> ...
> ...
> ...
>       if(problem)
>
>
servlet.getServletContext().getRequestDispatcher("/admin.do?doAction=alr
> eadyPrinted").forward(request, response);
>               return null;
>       }
>       else {
>               return new ByteArrayStreamInfo(contentType, myPdfBytes);
>       }
> }
>
> This works, but I always get a NullPointer, because I'm returning null
> to satisfy the method signature. The exception doesn't cause a problem
> for the user though, because the forward has already happened by then
> (and the user is happily viewing the JSP)
>
> Is there a better way to do this though - perhaps with
> ResourceStreamInfo instead?
>
> Regards
>
> Richard Gundersen
> Java Developer
>
> Email: [EMAIL PROTECTED]
> Phone: 01618302398
> Fax: 01618342536
> London Scottish Bank plc
> 24 Mount Street
> Manchester
> M2 3LS
>
>
> *** Disclaimer ***
>
> This electronic communication is confidential and for the exclusive
use of
> the addressee. It may contain private and confidential information.
The
> information, attachments and opinions contained in this E-mail are
those
> of its author only and do not necessarily represent those of London
> Scottish Bank PLC or any other members of the London Scottish Group.
>
> If you are not the intended addressee, you are prohibited from any
> disclosure, distribution or further copying or use of this
communication
> or the information in it or taking any action in reliance on it. If
you
> have received this communication in error please notify the
Information
> Security Manager at [EMAIL PROTECTED] as soon as possible and
delete
> the message from all places in your computer where it is stored.
>
> We utilise virus scanning software but we cannot guarantee the
security of
> electronic communications and you are advised to check any attachments
for
> viruses. We do not accept liability for any loss resulting from any
> corruption or alteration of data or importation of any virus as a
result
> of receiving this electronic communication.
>
> Replies to this E-mail may be monitored for operational or business
> reasons. London Scottish Bank PLC is regulated by the Financial
Services
> Authority.
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

*** Disclaimer *** 

This electronic communication is confidential and for the exclusive use of the 
addressee. It may contain private and confidential information. The 
information, attachments and opinions contained in this E-mail are those of its 
author only and do not necessarily represent those of London Scottish Bank PLC 
or any other members of the London Scottish Group. 

If you are not the intended addressee, you are prohibited from any disclosure, 
distribution or further copying or use of this communication or the information 
in it or taking any action in reliance on it. If you have received this 
communication in error please notify the Information Security Manager at [EMAIL 
PROTECTED] as soon as possible and delete the message from all places in your 
computer where it is stored. 

We utilise virus scanning software but we cannot guarantee the security of 
electronic communications and you are advised to check any attachments for 
viruses. We do not accept liability for any loss resulting from any corruption 
or alteration of data or importation of any virus as a result of receiving this 
electronic communication. 

Replies to this E-mail may be monitored for operational or business reasons. 
London Scottish Bank PLC is regulated by the Financial Services Authority.
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.

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

Reply via email to