[ 
https://issues.apache.org/jira/browse/TAPESTRY-2001?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12580608#action_12580608
 ] 

Howard M. Lewis Ship commented on TAPESTRY-2001:
------------------------------------------------

when  invoking HttpServletResponse.sendError() you shoudl not try and send a 
stream as well, just the message.  The container may use an error page to 
render the reponse, or it may wrap your message as an HTML page and send that 
back.

I think the correct solution here is to add a setStatus(int) method to 
Response.  It is accepible to set a status and then follow through with a 
streamed response, though the spec encourages this to only be used in cases 
where the status code represents a successful response.

Looking at the patch, I get antsy when I see a special case recognized using 
instanceof; that is a huge tipoff that the APIs or interfaces are insufficient.

> IllegalStateException if response.error set to other than 200
> -------------------------------------------------------------
>
>                 Key: TAPESTRY-2001
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2001
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: unspecified
>         Environment: Win/XP Java 1.5
>            Reporter: Sven Homburg
>            Priority: Minor
>         Attachments: ErrorStreamResponse.patch
>
>
> public class Test{
>   @Inject
>   private Response response;
>   StreamResponse onActivate( Object[] parameters ) throws IOException{
>     TextStreamResponse textStream = null;
>    
>     if( parameters == null || parameters.length != 2 )
>     {
>       textStream = new TextStreamResponse("text/html", "this page doesnt 
> exists");
>       response.sendError( 404, null );
>     }
>     return textStream;
>   }
> } 
> Error:
> ------------------------------------
> [ERROR] RequestExceptionHandler Processing of request failed with uncaught 
> exception: STREAM
> java.lang.IllegalStateException: STREAM
>         at org.mortbay.jetty.Response.getWriter(Response.java:571)
>         at 
> org.apache.tapestry.internal.services.ResponseImpl.getPrintWriter(ResponseImpl.java:47)
>         at $Response_1171072b273.getPrintWriter($Response_1171072b273.java)
>         at $Response_1171072b240.getPrintWriter($Response_1171072b240.java)
>         at 
> org.apache.tapestry.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:58)
>         at 
> $PageResponseRenderer_1171072b261.renderPageResponse($PageResponseRenderer_1171072b261.java)
>         at 
> org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:87)
>         at 
> $PageRenderRequestHandler_1171072b25d.handle($PageRenderRequestHandler_1171072b25d.java)
>         at 
> org.apache.tapestry.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:66)
>         at $Dispatcher_1171072b25f.dispatch($Dispatcher_1171072b25f.java)
>         at $Dispatcher_1171072b253.dispatch($Dispatcher_1171072b253.java)
>         at 
> org.apache.tapestry.services.TapestryModule$12.service(TapestryModule.java:905)
> ------------------------------------ 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to