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]