You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy Layman <ra...@aswethink.com> on 2001/08/24 21:19:55 UTC

RE: response.sendRedirect problems with IE5.5

	Calling response.sendRedirect does not stop the execution of a JSP
page.  You are responsible for returning from the _jspService method after
calling sendRedirect (by placing a return statement in your JSP).  

	What is actually happening is that Netscape is thinking that its
smarter than the web developer by ignoring everything after the redirect
command while IE is actually doing the correct thing (for once) and showing
all the HTML returned by the server.

	Randy


> -----Original Message-----
> From: Eric Simpson [mailto:esimp@home.com]
> Sent: Friday, August 24, 2001 4:42 PM
> To: tomcat-user@jakarta.apache.org
> Subject: response.sendRedirect problems with IE5.5
> 
> 
> When I call the response.sendRedirect() function from a Java 
> Bean I get
> a response that already has data in it, the only problem
> is that the response shouldn't have any data in it already.  I have a
> function call before anything is written to the output buffer
> that determines if this page should call a response.sendRedirect().
> 
> The weird thing is that only IE has the data that shouldn't 
> be returned
> in the html page (from the "view source" option).  Netscape 
> doesn't have
> the garbage data when I "view source".
> 
> What is going on here?
> 
> Info:
> Tomcat 3.2.3
> jdk1.2.2
> NT 4.0
> 
> ### data that shouldn't be returned ###
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/REC-html40/loose.dtd">
> 
> <html>
> <head>
> 
>  ... omitted data ...
> 
>    CircImage4.src = HTTP/1.1 200 OK
> Via: 1.0 MAIL
> Connection: Keep-Alive
> Content-Length: 1536
> Content-Type: text/html
> Last-Modified: Thu, 16 Aug 2001 16:54:28 GMT
> Servlet-Engine: Tomcat Web Server/3.2.3 (JSP 1.1; Servlet 2.2; Java
> 1.2.2; Windows NT 4.0 x86; java.vendor=Sun Microsystems Inc.)
> 
> ### page that should be returned ###
> <html>
> <head>
> ... rest of response ...
> 
> ### relevent parts of index. jsp ###
> /******* session operations *******/
> try {
>     sessionBean.setResponse(response);
>     sessionBean.setRequest(request);
>     sessionBean.setIP(request.getRemoteAddr());
>     sessionBean.setFile(path + name);
>     sessionBean.log();
> }
> catch(IOException ignored) { }
> catch(SQLException ignored) { }
> 
> // output header,nav
> application.getRequestDispatcher("/main.jsp").include(request,
> response);
> 
> // output static page if no processing needed on content
> if(proc == null || proc.equals("false")) {
> 
> application.getRequestDispatcher("/static.jsp").include(reques
> t,response);
> 
> }
> else {
>     application.getRequestDispatcher("/" +
> name).include(request,response);
> }
> 
> // output footer
> application.getRequestDispatcher("/footer.jsp").include(reques
> t,response);
> 
> %>
> 
> ### relevent portion of SessionBean ###
>     public void log() {
>          ...
>          if(visits == 1) {
>              res.sendRedirect("/intro.html");
>          }
>         ...
>     }
> 
>