Apologies for my ignorance, but I'm new to custom tags and tag files (this is
my first app using them). 

You reference the restriction that "only if no content has already been sent
to the client". Is there something different about how or when response
content gets sent to the client in the Jasper-generated code for tag files
versus the Jasper-generated code for JSP's? Most of my tag files look very
similar to my JSP's, just with attributes, and code of this style in JSP's
propagates exceptions all cases I've seen so far (ie: I get the Apache error
page, which is what I want in my test environment):

...some html
<% some scriptlet %>
...more html
<% more scriptlet %>
etc...

I do use some tags that use JSTL rather than scriptlets. Again, is there
something about the way the Jasper-generated code for tags that use JSTL
handles the sending of the response differently from normal JSP's?

Perhaps the simplest question would be this: Is there a best-practice
recommendation for developing tag files that are guaranteed to allow
exceptions to bubble up (ie: not send any response to client until its
containing page is completely processed)?

Thank you for your help,

Bobby



David Delbecq-2 wrote:
> 
> Showing error pages for tomcat means
> 1) set the current http status header to an error one (5xx,4xx,etc
> depending on error type)
> 2) send in body of response a html showing error
> This can *only* be done if no content has already been send to client
> (because of http specification).
> 
> Th be sure your exeception get to the user page, you must ensure nothing
> is send to client before response is fully generated. The only way i
> know to do this is to cache locally the response until servlet return
> from processing. And only hat this moment send this cached response to
> the client socket. To do this, you have to implement a servlet filter
> that provide a wrapper Response to the filter chain and have this
> wrapped response implement the response stream as a
> ByteArrayOutputStream of something alike. When the chain returns without
> exception, you then have to copy that memory stream to original Response
> Stream. The draw back is that, if you have lots of simultaneous request
> that send response of a few hundred K in size, this takes lots of memory.
> 
> an other solution is to use the <%@ page buffer=sizekb %> which will
> cache a small amount of response before sending anything to socket, a
> good value for buffer size can reduce the odds of having no error
> response in cas of errors. (This will anyway fail if any tag call
> flush() on response stream)
> 
> kempo bob a écrit :
>> I have a JSP that uses several tags implemented as tag files (not classic
>> custom tag handlers). I want all exceptions to bubble up and be displayed
>> on
>> the standard apache error page, but some exceptions are being swallowed
>> silently, depending on where they occur relative to the tag being
>> invoked.
>>
>> example where I get the error page:
>>
>> <%
>>    throw new FooException();
>> %>
>> <mytags: tag1 attr1="foo" />
>>
>> example where the exception just goes to the localhost log:
>>
>> <mytags: tag1 attr1="foo" />
>> <%
>>    throw new FooException();
>> %>
>>
>> I looked at the generated source for the JSP, and it looks like
>> PageContext.handlePageException() might be the culprit. What can I do to
>> make all exceptions percolate to the top without being swallowed?
>>
>> Thanks,
>>
>> Bobby
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JSPs-with-custom-tags-swallow-exceptions-tf3842796.html#a10886356
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to