Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 85934 invoked from network); 2 Aug 2007 01:49:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Aug 2007 01:49:37 -0000 Received: (qmail 15334 invoked by uid 500); 2 Aug 2007 01:49:28 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 15323 invoked by uid 500); 2 Aug 2007 01:49:28 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 15312 invoked by uid 99); 2 Aug 2007 01:49:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Aug 2007 18:49:28 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paulus.benedictus@gmail.com designates 66.249.92.172 as permitted sender) Received: from [66.249.92.172] (HELO ug-out-1314.google.com) (66.249.92.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2007 01:49:17 +0000 Received: by ug-out-1314.google.com with SMTP id o4so387912uge for ; Wed, 01 Aug 2007 18:49:00 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=DwaFujoDJo/uCDMh70VvCaSsx2GCOdmELUYMOqF36jD7H2U6J+lnT2xkfWq2Hp2ddnPfIPZGqz5gOjP1ThdA+bUyZ60SjWL2gFiFnvf9FDmjP73hPWK6t/xrgSCHjhvj6TAjMuO9DU3H+d7q9VTvm2vYWn1IlEN6pBxPKtvRULY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=EYl1TCjBO2VETXbyUHizpwX9DXk2ABsoujZSiPVh2POB+wfU8GMcCOO9OxGHMV5ryy34gZH/7wCykruDS4DtGzdQB3b0KzLCHeyqoJPa9tlboAIIVn3I5+LrDwsB72qXUQKMlBLk7YJMUfAvYWMN4XbJxn6Ycj1sSwVunQA5C2Q= Received: by 10.66.220.17 with SMTP id s17mr1775472ugg.1186019340443; Wed, 01 Aug 2007 18:49:00 -0700 (PDT) Received: by 10.67.15.18 with HTTP; Wed, 1 Aug 2007 18:49:00 -0700 (PDT) Message-ID: Date: Wed, 1 Aug 2007 20:49:00 -0500 From: "Paul Benedict" Sender: paulus.benedictus@gmail.com To: "Struts Users Mailing List" Subject: Re: DownloadAction and a normal Forward In-Reply-To: <8742.170.201.180.136.1185982332.squirrel@webmail.chiron.lunarpages.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_53194_24773431.1186019340381" References: <46BB113A91AE694EB5BE73A9C030EC9283CC32@lsbexc05.london-scottish.com> <8742.170.201.180.136.1185982332.squirrel@webmail.chiron.lunarpages.com> X-Google-Sender-Auth: ca93f4abab3fdde4 X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_53194_24773431.1186019340381 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Who is throwing the NPE? I can't tell by your code what's causing it. On 8/1/07, Frank W. Zammetti wrote: > > You know, I just reread what your trying to do... have you tried using a > global exception handler? I'm not sure you'll be able to catch the > exception with one, but if you give it a try and you can, there you go, > you can forward as desired from there. > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > AIM/Yahoo: fzammetti > MSN: fzammetti@hotmail.com > 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 10:38 am, Gundersen, Richard wrote: > > 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: richard.gundersen@london-scottish.com > > Phone: 01618302398 > > Fax: 01618342536 > > London Scottish Bank plc > > 24 Mount Street > > Manchester > > M2 3LS > > > > -----Original Message----- > > From: Frank W. Zammetti [mailto:fzlists@omnytex.com] > > 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: fzammetti@hotmail.com > > 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: richard.gundersen@london-scottish.com > >> 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 ISM@London-Scottish.com 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: user-unsubscribe@struts.apache.org > >> For additional commands, e-mail: user-help@struts.apache.org > >> > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > ______________________________________________________________________ > > 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 ISM@London-Scottish.com 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: user-unsubscribe@struts.apache.org > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > ------=_Part_53194_24773431.1186019340381--