This question ended up getting answered back on the JSP list (many thanks to Hans Bergsten!). The spec very clearly calls out the issue in section JSP.4.4:
"An included page only has access to the JspWriter object and it cannot set headers. This precludes invoking methods like setCookie(). Attempts to invoke these methods will be ignored." My oversight. Thanks anyway. Jay > -----Original Message----- > From: Jay Burgess [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 11:08 AM > To: [EMAIL PROTECTED] > Subject: Why ignore sendRedirect() for an include? > > > I started this discussion on the JSP list, but am led to > believe now that > this is a Tomcat issue. Can someone explain otherwise? > > My problem is that a sendRedirect() issued by my servlet is not being > honored by Tomcat 4.0.3. The servlet is being called via a > <jsp:include> > block from within a JSP. The sendRedirect() is the first thing in my > doGet(). As long as the response hasn't been committed, > this should be > legal, right? (I confirmed that the response had not been > committed with > res.isCommitted() .) > > To confuse me even more, I found the following in the Tomcat source > (ApplicationHttpResponse.java): > > /** > * Disallow <code>sendRedirect()</code> calls on an > included response. > * > * @param location The new location > * > * @exception IOException if an input/output error occurs > */ > public void sendRedirect(String location) throws IOException { > if (!included) > ((HttpServletResponse) > getResponse()).sendRedirect(location); > } > > Can someone confirm that the reason my sendRedirect() is > failing is because > of the above (!included) check, and even more importantly, > WHY you don't > allow sendRedirect()'s on an included response? > > Thanks. > > Jay > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>