From tomcat-user-return-97389-apmail-jakarta-tomcat-user-archive=jakarta.apache.org@jakarta.apache.org Sat Apr 03 15:35:29 2004 Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@www.apache.org Received: (qmail 72436 invoked from network); 3 Apr 2004 15:35:29 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Apr 2004 15:35:29 -0000 Received: (qmail 12528 invoked by uid 500); 3 Apr 2004 15:35:03 -0000 Delivered-To: apmail-jakarta-tomcat-user-archive@jakarta.apache.org Received: (qmail 12501 invoked by uid 500); 3 Apr 2004 15:35:03 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 12460 invoked from network); 3 Apr 2004 15:35:02 -0000 Received: from unknown (HELO sid.armstrong.com) (204.74.20.252) by daedalus.apache.org with SMTP; 3 Apr 2004 15:35:02 -0000 Received: from joedog.org (pcp01470022pcs.lncstr01.pa.comcast.net [68.82.237.147]) by sid.armstrong.com (8.12.8p1/8.12.8) with ESMTP id i33FJUtW032483 for ; Sat, 3 Apr 2004 10:19:30 -0500 Message-ID: <406ED9A6.3000209@joedog.org> Date: Sat, 03 Apr 2004 10:35:02 -0500 From: Tim Funk Organization: Human being User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en, es-mx, de, sv MIME-Version: 1.0 To: Tomcat Users List Subject: Re: SendRedirect and IllegalStateException References: <1E8A41FD-857C-11D8-9ADE-000A95C58AD6@goshen.edu> In-Reply-To: <1E8A41FD-857C-11D8-9ADE-000A95C58AD6@goshen.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N It should display company news. And you should see in your logs an IllegalStateException. (And the stack trace should contain the sendRedirect method) -Tim Umesha Balasubramaniam wrote: > Hi Everyone, > > I am brushing up on my servlet programming after a long lay off. I was > working through this book and came across the perils of using > sendRedirect after commiting the response. My understanding according to > the book and the 2.4 servlet api is that if you call the sendRedirect > method after outputting something with the PrintWriter and flushing it > should throw an Illegal exception, right? I want to know if anyone out > there also noticed this or am I doing something wrong? > Tomcat version: 5.0.19 > OS: Mac OS X 10.3.3 > J2SDK: 1.4.2_03 > > My code: > import java.io.*; > import javax.servlet.*; > import javax.servlet.http.*; > > public class RedirectException extends HttpServlet{ > > public void doGet(HttpServletRequest request, > HttpServletResponse response) throws > ServletException, > IOException { > > > PrintWriter writer = response.getWriter(); > writer.println(""); > writer.println(""); > writer.println("Company News!!"); > writer.println(""); > writer.println(""); > writer.flush(); > response.sendRedirect("http://news.bbc.co.uk"); > > > > > } > } > > What is happening is that the browser is displaying Company News! > --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-user-help@jakarta.apache.org