You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by cordenier christophe <ch...@gmail.com> on 2009/10/12 13:02:45 UTC

Re: NPE when using Response.sendRedirect(String url) to forward to offsite address.

Hello

Try by returning a java.net.URL from your activate method.
This should work i think.

Regards,
Christophe.

2009/10/12 Martin Reurings <ma...@windgazer.nl>

> Hi everyone,
>
> For various reasons (that are good enough for our team ;) ) we have to make
> use of a sendRedirect to forward to an offsite url. This works fine when I
> do so from an event, such as @OnEvent(value=EventConstants.SUCCESS) but
> throws a NPE when attempting to do so from any phase of the render-request
> :(
>
> Even the onActivate() counts as one of the phases for which it fails
> unfortunately. I can redirect inside T5 just fine, using the obvious method
> of returning a Class or Link, but I need to be able to redirect off-site as
> well! As a results my post has two goals:
> 1) I want to establish if this problem is a bug and if so should I report
> it, or is it already reported (I could not find it in Jira).
> 2) Can anybody come up with a work-around for this bug. The behaviour I
> need is that a user-request to 'a page' causes the page to redirect to an
> external url, without user interaction. (Currently I have a form with hidden
> input containing pertinent information, and the user needs to click the
> form-button).
>
> Some additional technical information:
> - I am using Tapestry 5.1.0.5
> - This is the start if the stacktrace root-cause:
> 12-Oct-2009 11:25:43 org.apache.catalina.core.StandardWrapperValve invoke
> SEVERE: Servlet.service() for servlet default threw exception
> java.lang.NullPointerException
>   at
> org.apache.tapestry5.internal.services.ResponseCompressionAnalyzerImpl.isCompressable(ResponseCompressionAnalyzerImpl.java:65)
>   at
> $ResponseCompressionAnalyzer_12448028aeb.isCompressable($ResponseCompressionAnalyzer_12448028aeb.java)
>   at
> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.openResponseOutputStream(BufferedGZipOutputStream.java:77)
>   at
> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.checkForCutover(BufferedGZipOutputStream.java:70)
>   at
> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.write(BufferedGZipOutputStream.java:116)
>   at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
>   at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
>   at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
>   at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
>   at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
>   at java.io.BufferedWriter.write(BufferedWriter.java:212)
>   at java.io.PrintWriter.write(PrintWriter.java:384)
>   at java.io.PrintWriter.write(PrintWriter.java:401)
>   at java.io.PrintWriter.print(PrintWriter.java:532)
>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:367)
>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>   at org.apache.tapestry5.dom.Document.toMarkup(Document.java:163)
>   at org.apache.tapestry5.dom.Node.toMarkup(Node.java:80)
>   at
> org.apache.tapestry5.internal.services.MarkupWriterImpl.toMarkup(MarkupWriterImpl.java:57)
>   at
> org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: NPE when using Response.sendRedirect(String url) to forward to offsite address.

Posted by Martin Reurings <ma...@windgazer.nl>.
Hi Cristophe,

Thanks for pointing that out, you're a legend! Works a charm! Even after 
working with T5 for 2 years orso I still get stumped by how simple some 
solutions are ;)

Regards,

 Martin

cordenier christophe wrote:
> Hello
>
> Try by returning a java.net.URL from your activate method.
> This should work i think.
>
> Regards,
> Christophe.
>
> 2009/10/12 Martin Reurings <ma...@windgazer.nl>
>
>   
>> Hi everyone,
>>
>> For various reasons (that are good enough for our team ;) ) we have to make
>> use of a sendRedirect to forward to an offsite url. This works fine when I
>> do so from an event, such as @OnEvent(value=EventConstants.SUCCESS) but
>> throws a NPE when attempting to do so from any phase of the render-request
>> :(
>>
>> Even the onActivate() counts as one of the phases for which it fails
>> unfortunately. I can redirect inside T5 just fine, using the obvious method
>> of returning a Class or Link, but I need to be able to redirect off-site as
>> well! As a results my post has two goals:
>> 1) I want to establish if this problem is a bug and if so should I report
>> it, or is it already reported (I could not find it in Jira).
>> 2) Can anybody come up with a work-around for this bug. The behaviour I
>> need is that a user-request to 'a page' causes the page to redirect to an
>> external url, without user interaction. (Currently I have a form with hidden
>> input containing pertinent information, and the user needs to click the
>> form-button).
>>
>> Some additional technical information:
>> - I am using Tapestry 5.1.0.5
>> - This is the start if the stacktrace root-cause:
>> 12-Oct-2009 11:25:43 org.apache.catalina.core.StandardWrapperValve invoke
>> SEVERE: Servlet.service() for servlet default threw exception
>> java.lang.NullPointerException
>>   at
>> org.apache.tapestry5.internal.services.ResponseCompressionAnalyzerImpl.isCompressable(ResponseCompressionAnalyzerImpl.java:65)
>>   at
>> $ResponseCompressionAnalyzer_12448028aeb.isCompressable($ResponseCompressionAnalyzer_12448028aeb.java)
>>   at
>> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.openResponseOutputStream(BufferedGZipOutputStream.java:77)
>>   at
>> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.checkForCutover(BufferedGZipOutputStream.java:70)
>>   at
>> org.apache.tapestry5.internal.gzip.BufferedGZipOutputStream.write(BufferedGZipOutputStream.java:116)
>>   at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
>>   at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:395)
>>   at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:136)
>>   at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
>>   at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111)
>>   at java.io.BufferedWriter.write(BufferedWriter.java:212)
>>   at java.io.PrintWriter.write(PrintWriter.java:384)
>>   at java.io.PrintWriter.write(PrintWriter.java:401)
>>   at java.io.PrintWriter.print(PrintWriter.java:532)
>>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:367)
>>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>>   at org.apache.tapestry5.dom.Element.writeChildMarkup(Element.java:840)
>>   at org.apache.tapestry5.dom.Element.toMarkup(Element.java:356)
>>   at org.apache.tapestry5.dom.Document.toMarkup(Document.java:163)
>>   at org.apache.tapestry5.dom.Node.toMarkup(Node.java:80)
>>   at
>> org.apache.tapestry5.internal.services.MarkupWriterImpl.toMarkup(MarkupWriterImpl.java:57)
>>   at
>> org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:67)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>