Also, I believe that once you do an include in j2ee, you cannot change
headers. Since a "sendRedirect()" method requires a header to be changed
that means you can't do a redirect inside of an include.
(See j2ee 1.4 spec section 8.3)
"It cannot set headers or call any methods that affects the headers of the
response. Any attempt to do so must be ignored."
As a workaround you could use the static include directive for your target
page:
<%@ include file="relativeURL" %>
That has different behavior since it combines the two pages into one, then
compiles them into a single class. Sometimes that class can become larger
than java will allow and the page won't compile. So be careful about too
many static include directives.
-- Adam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ATG_Tech" group.
To post to this group, send email to atg_...@googlegroups.com
To unsubscribe from this group, send email to
atg_tech-u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atg_tech?hl=en
-~----------~----~----~----~------~----~------~--~---
you can increase the buffer size in the page directive like:
<%@ page ...... buffer="none|8kb|sizekb" ... %>
Be careful making the buffer too large as it can burn memory quickly
if your pages are large.
Gordon
Even if there is no whitespace and/or the page buffer is set large enough that it doesn’t flush before the include, I think it just won’t work once a call to RequestDispatcher.include() has been made.
The target “servlet” (in this case a jsp page) can’t set headers. So that means it can’t redirect.
“The include method of the RequestDispatcher interface may be called at ANY time. The target servlet of the include method has access to all aspects of the request object, but its use of the response object is more limited. It can only write information to the ServletOutputStream or Writer of the response object and commit a response by writing content past the end of the response buffer, or by explicitly calling the flushBuffer method of the ServletResponse interface. It CANNOT set headers or call any method that affects the headers of the response. Any attempt to do so must be ignored.
The forward method of the RequestDispatcher interface may be called by the calling servlet ONLY when NO output has been committed to the client. If output data exists in the response buffer that has not been committed, the content must be cleared before the target servlet's service method is called. If the response has been committed, an IllegalStateException must be thrown.”
I don’t see that restriction listed in the paragraph for RequestDispatcher.forward(). So dspel:forward might be another workaround instead of the static include directive. The forward still has the restriction that the response can’t be committed. So you’ll need to make sure there is no whitespace being written before the Redirect droplet.
Performance wise it’s probably better to do the static include directive and avoid the overhead of doing a forward just to trigger the redirect.
-- Adam
because the part before the include may include a (partial) page, the
redirect fails.
You cannot reply with a page and then halfway decide that you meant to
return a redirect...you need to decide very early whether a redirect
is required instead of a page rendering.
Wilco