You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by renen <re...@121.co.za> on 2007/11/09 16:09:47 UTC

jsp done processing!

Hi Folks,

I want to tell the browser / Tomcat that I'm done processing my JSP page
(ie, the little spinning icon in Firefox should stop spinning!). 

However, I still want to log a couple of things (duration, browser info
etc). But, the users' browser doesn't need to be tied up while this happens.

One way to do that would seem to be to call response.flush(). However,
Tomcat seems to have issues with this (google: response.flush tomcat).
Indeed, it doesn't seem to do anything at all.

The one way I did manage to communicate that I was done was to call:

response.getWriter().flush();
response.getWriter().close();

But, on certain (tiny) pages, it seems to kill all the content. Which is a
bit unfortunate!

Is there a way that I can signal to Tomcat / the browser / the servlet
filters, that my JSP page is done?


The page that doesn't render when those two lines of code are included is as
follows:

<%@ page language="java" import="za.co.oneTwoOne.web.*"
pageEncoding="ISO-8859-1"%>
<%
Session myPage = new Session(request, response);
pageContext.setAttribute("myPage", myPage);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <body>
    ProcessID <%=myPage.getParameter("ProcessID") %> took
<%=myPage.getInt("exec ProcessGetExecutionTime ?", "ProcessID*") %> ms to
serve.
  </body>
</html>

<%
myPage.terminate();
%>


I really appreciate your input!

Renen.





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


Re: jsp done processing!

Posted by Lucas Galfaso <lg...@gmail.com>.
Hi,
  Never do a
response.getWriter().close();
  A good design would not ask you to close something that you did not
open, and this is one of those cases.
  The full response is sent when your page "releases the thread" that
is working on this request. This is, if you want to do some processing
and you want to send the response to the browser at the same time, you
have to create a new thread.

Regards,
 -lg


On Nov 9, 2007 12:09 PM, renen <re...@121.co.za> wrote:
> Hi Folks,
>
> I want to tell the browser / Tomcat that I'm done processing my JSP page
> (ie, the little spinning icon in Firefox should stop spinning!).
>
> However, I still want to log a couple of things (duration, browser info
> etc). But, the users' browser doesn't need to be tied up while this happens.
>
> One way to do that would seem to be to call response.flush(). However,
> Tomcat seems to have issues with this (google: response.flush tomcat).
> Indeed, it doesn't seem to do anything at all.
>
> The one way I did manage to communicate that I was done was to call:
>
> response.getWriter().flush();
> response.getWriter().close();
>
> But, on certain (tiny) pages, it seems to kill all the content. Which is a
> bit unfortunate!
>
> Is there a way that I can signal to Tomcat / the browser / the servlet
> filters, that my JSP page is done?
>
>
> The page that doesn't render when those two lines of code are included is as
> follows:
>
> <%@ page language="java" import="za.co.oneTwoOne.web.*"
> pageEncoding="ISO-8859-1"%>
> <%
> Session myPage = new Session(request, response);
> pageContext.setAttribute("myPage", myPage);
> %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
>   <body>
>     ProcessID <%=myPage.getParameter("ProcessID") %> took
> <%=myPage.getInt("exec ProcessGetExecutionTime ?", "ProcessID*") %> ms to
> serve.
>   </body>
> </html>
>
> <%
> myPage.terminate();
> %>
>
>
> I really appreciate your input!
>
> Renen.
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: jsp done processing!

Posted by Bill Barker <wb...@wilshire.com>.
"renen" <re...@121.co.za> wrote in message 
news:13318982.104581194621048070.JavaMail.SYSTEM@IPDMFZ0504MIA...
> Hi Folks,
>
> I want to tell the browser / Tomcat that I'm done processing my JSP page
> (ie, the little spinning icon in Firefox should stop spinning!).
>
> However, I still want to log a couple of things (duration, browser info
> etc). But, the users' browser doesn't need to be tied up while this 
> happens.
>
> One way to do that would seem to be to call response.flush(). However,
> Tomcat seems to have issues with this (google: response.flush tomcat).
> Indeed, it doesn't seem to do anything at all.
>
> The one way I did manage to communicate that I was done was to call:
>
> response.getWriter().flush();
> response.getWriter().close();
>
> But, on certain (tiny) pages, it seems to kill all the content. Which is a
> bit unfortunate!
>
> Is there a way that I can signal to Tomcat / the browser / the servlet
> filters, that my JSP page is done?
>

<% out.close(); %>

The problem is that your page is writing to the JspWriter implicit object 
"out", which on the page below is buffering the first 8Kb (the default 
value) of the page before sending it to the request.getWriter().  So when 
you close request.getWriter(), you prevent the JspWriter from sending it's 
buffered output.  Also note, that you have to make certain that there are no 
characters in the file (not even a newline) after the expression <% 
out.close() %>, or you will start filling up your logs with IOExceptions.

This will tell Tomcat to tell the browser that this is all the output it 
will receive.  Unless you are doing fancy Response wrapping, your Filters 
will find out that you are done in the usual way when you fall off the end 
of the page.



>
> The page that doesn't render when those two lines of code are included is 
> as
> follows:
>
> <%@ page language="java" import="za.co.oneTwoOne.web.*"
> pageEncoding="ISO-8859-1"%>
> <%
> Session myPage = new Session(request, response);
> pageContext.setAttribute("myPage", myPage);
> %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
>  <body>
>    ProcessID <%=myPage.getParameter("ProcessID") %> took
> <%=myPage.getInt("exec ProcessGetExecutionTime ?", "ProcessID*") %> ms to
> serve.
>  </body>
> </html>
>
> <%
> myPage.terminate();
> %>
>
>
> I really appreciate your input!
>
> Renen.
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




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