You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jonathan Eric Miller <to...@shark.uchicago.edu> on 2001/08/21 23:48:23 UTC

Possible to return multiple responses/pages for a request?

I'm wondering if it is possible to return multiple responses/pages from a
given request?

I have a servlet that performs some processing after a form is submitted to
it. This processing sometimes takes several seconds to complete. What I want
to do is first display a page which says "Processing your request, please
wait..." Then, after the processing is done, I want to display another page.
The second page should replace the first page in the user's browser.

Does anyone know if this is possible to do? I want to say that at some point
someone told me that you can do this with "multi-part" something-or-other?

Basically, I want to do something like the following, but, it doesn't work.

   resp.setContentType("text/html");

   PrintWriter pw = resp.getWriter();

   pw.println("<html><head><title>Test</title></head><body>");

   pw.println("<p>Please wait...</p>
");

   pw.println("</body></html>");

   pw.close();

   Thread.sleep(10000);

   resp.setContentType("text/html");

   pw = resp.getWriter();

   pw.println("<html><head><title>Test</title></head><body>");

   pw.println("<p>Processing completed...</p>");

   pw.println("</body></html>");

   pw.close();

Jon



Re: Possible to return multiple responses/pages for a request?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 21 Aug 2001, Pierre Carette wrote:

> Where can I download a compatible version of the servlet API for tomcat 3.2
> ?
>

If you just need the classes themselves, the servlet.jar included with
Tomcat is all you need.  If you want the javadocs as well (and the servlet
spec, hint hint :-), go to:

  http://java.sun.com/products/servlet/download.html

> Thanks,
>
> Pierre
>

Craig McClanahan


RE: Possible to return multiple responses/pages for a request?

Posted by "Rob S." <rs...@home.com>.
http://jakarta.apache.org/tomcat/index.html

Navigate to download the binary for v4 and it'll be in the same dir on the
server.

- r

> -----Original Message-----
> From: Pierre Carette [mailto:pierre-carette@home.com]
> Sent: Tuesday, August 21, 2001 9:32 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Possible to return multiple responses/pages for a request?
>
>
> Where can I download a compatible version of the servlet API for
> tomcat 3.2
> ?
>
> Thanks,
>
> Pierre
>
> ----- Original Message -----
> From: "Shunsuke Masuda" <sm...@pp.iij4u.or.jp>
> To: <to...@jakarta.apache.org>
> Sent: Tuesday, August 21, 2001 6:06 PM
> Subject: Re: Possible to return multiple responses/pages for a request?
>
>
> > Hello,
> >
> > I have the same requirement on the current project.
> >
> > What I am doing is to use threads  for heavy tasks and
> > let browsers reload by "<meta .... Refresh....>".
> > References to the threads are setAttr'ed into HttpSession,
> > and a servlet checks on each reload whether or not the
> > threads complete.
> >
> > Shunsuke Masuda
> >
> > ----- Original Message -----
> > From: "Jonathan Eric Miller" <to...@shark.uchicago.edu>
> > To: "Tomcat User List" <to...@jakarta.apache.org>
> > Sent: Wednesday, August 22, 2001 6:48 AM
> > Subject: Possible to return multiple responses/pages for a request?
> >
> >
> > > I'm wondering if it is possible to return multiple
> responses/pages from
> a
> > > given request?
> > >
> > > I have a servlet that performs some processing after a form
> is submitted
> > to
> > > it. This processing sometimes takes several seconds to
> complete. What I
> > want
> > > to do is first display a page which says "Processing your request,
> please
> > > wait..." Then, after the processing is done, I want to display another
> > page.
> > > The second page should replace the first page in the user's browser.
> > >
> >
> >
> >
>
>


Re: Possible to return multiple responses/pages for a request?

Posted by Pierre Carette <pi...@home.com>.
Where can I download a compatible version of the servlet API for tomcat 3.2
?

Thanks,

Pierre

----- Original Message -----
From: "Shunsuke Masuda" <sm...@pp.iij4u.or.jp>
To: <to...@jakarta.apache.org>
Sent: Tuesday, August 21, 2001 6:06 PM
Subject: Re: Possible to return multiple responses/pages for a request?


> Hello,
>
> I have the same requirement on the current project.
>
> What I am doing is to use threads  for heavy tasks and
> let browsers reload by "<meta .... Refresh....>".
> References to the threads are setAttr'ed into HttpSession,
> and a servlet checks on each reload whether or not the
> threads complete.
>
> Shunsuke Masuda
>
> ----- Original Message -----
> From: "Jonathan Eric Miller" <to...@shark.uchicago.edu>
> To: "Tomcat User List" <to...@jakarta.apache.org>
> Sent: Wednesday, August 22, 2001 6:48 AM
> Subject: Possible to return multiple responses/pages for a request?
>
>
> > I'm wondering if it is possible to return multiple responses/pages from
a
> > given request?
> >
> > I have a servlet that performs some processing after a form is submitted
> to
> > it. This processing sometimes takes several seconds to complete. What I
> want
> > to do is first display a page which says "Processing your request,
please
> > wait..." Then, after the processing is done, I want to display another
> page.
> > The second page should replace the first page in the user's browser.
> >
>
>
>


Re: Possible to return multiple responses/pages for a request?

Posted by Jonathan Eric Miller <to...@shark.uchicago.edu>.
I have a book named Java Servlet Programming which mentions a class called
MultipartResponse that looks like it might do what I want, but, it says that
IE doesn't support it. Also, it seems to be using a class provided by
oreilly. It would be nice to be able to handle the problem in a synchronous
fashion.

Jon

----- Original Message -----
From: "Shunsuke Masuda" <sm...@pp.iij4u.or.jp>
To: <to...@jakarta.apache.org>
Sent: Tuesday, August 21, 2001 8:06 PM
Subject: Re: Possible to return multiple responses/pages for a request?


> Hello,
>
> I have the same requirement on the current project.
>
> What I am doing is to use threads  for heavy tasks and
> let browsers reload by "<meta .... Refresh....>".
> References to the threads are setAttr'ed into HttpSession,
> and a servlet checks on each reload whether or not the
> threads complete.
>
> Shunsuke Masuda
>
> ----- Original Message -----
> From: "Jonathan Eric Miller" <to...@shark.uchicago.edu>
> To: "Tomcat User List" <to...@jakarta.apache.org>
> Sent: Wednesday, August 22, 2001 6:48 AM
> Subject: Possible to return multiple responses/pages for a request?
>
>
> > I'm wondering if it is possible to return multiple responses/pages from
a
> > given request?
> >
> > I have a servlet that performs some processing after a form is submitted
> to
> > it. This processing sometimes takes several seconds to complete. What I
> want
> > to do is first display a page which says "Processing your request,
please
> > wait..." Then, after the processing is done, I want to display another
> page.
> > The second page should replace the first page in the user's browser.
> >
>
>
>


Re: Possible to return multiple responses/pages for a request?

Posted by Shunsuke Masuda <sm...@pp.iij4u.or.jp>.
Hello,

I have the same requirement on the current project.

What I am doing is to use threads  for heavy tasks and
let browsers reload by "<meta .... Refresh....>".
References to the threads are setAttr'ed into HttpSession,
and a servlet checks on each reload whether or not the
threads complete.

Shunsuke Masuda

----- Original Message -----
From: "Jonathan Eric Miller" <to...@shark.uchicago.edu>
To: "Tomcat User List" <to...@jakarta.apache.org>
Sent: Wednesday, August 22, 2001 6:48 AM
Subject: Possible to return multiple responses/pages for a request?


> I'm wondering if it is possible to return multiple responses/pages from a
> given request?
>
> I have a servlet that performs some processing after a form is submitted
to
> it. This processing sometimes takes several seconds to complete. What I
want
> to do is first display a page which says "Processing your request, please
> wait..." Then, after the processing is done, I want to display another
page.
> The second page should replace the first page in the user's browser.
>



Re: Possible to return multiple responses/pages for a request?

Posted by Jonathan Eric Miller <to...@shark.uchicago.edu>.
Thanks for the response. Currently, I'm not doing any client-side scripting
though and I want to try to avoid doing so if at all possible. I appreciate
the suggestion though. It's something to think about.

Jon

----- Original Message -----
From: "Jim Urban" <ji...@netsteps.net>
To: <to...@jakarta.apache.org>
Sent: Wednesday, August 22, 2001 7:24 AM
Subject: RE: Possible to return multiple responses/pages for a request?


> This is an unproven browser side solution which involves JavaScript and
> framesets...
>
> 1.  The page that submits to the long running servlet should consists of a
> frame set.  The one frame is visible and displays the page that allows the
> user to input the data.  The second frame is invisible and contains a form
> containing duplicate form variables.
>
> 2.  The submit button on the user input page does the following:
> 1.  Copies the contents of its form variables to the hidden frame's form
> variables.
> 2.  Redirects the current frame to your "Processing your request, please
> wait..." page.
>
> 3.  Your "Processing your request, please wait..." contains an "onload"
> function which calls a JavaScript function in the hidden frame telling the
> hidden frame to submit itself to your servlet, targeting either the
visible
> frame or "top" to replace the frameset completely.
>
>
> I have not tried this, but I think it should work.  If you try it, please
> let me know if it works.
>
> Jim Urban
> Product Manager
> Netsteps Inc.
> Suite 505E
> 1 Pierce Pl.
> Itasca, IL  60143
> Voice:  (630) 250-3045 x2164
> Fax:  (630) 250-3046
>
>
> -----Original Message-----
> From: Jonathan Eric Miller [mailto:tomcat@shark.uchicago.edu]
> Sent: Tuesday, August 21, 2001 4:48 PM
> To: Tomcat User List
> Subject: Possible to return multiple responses/pages for a request?
>
>
> I'm wondering if it is possible to return multiple responses/pages from a
> given request?
>
> I have a servlet that performs some processing after a form is submitted
to
> it. This processing sometimes takes several seconds to complete. What I
want
> to do is first display a page which says "Processing your request, please
> wait..." Then, after the processing is done, I want to display another
page.
> The second page should replace the first page in the user's browser.
>
> Does anyone know if this is possible to do? I want to say that at some
point
> someone told me that you can do this with "multi-part" something-or-other?
>
> Basically, I want to do something like the following, but, it doesn't
work.
>
>    resp.setContentType("text/html");
>
>    PrintWriter pw = resp.getWriter();
>
>    pw.println("<html><head><title>Test</title></head><body>");
>
>    pw.println("<p>Please wait...</p>
> ");
>
>    pw.println("</body></html>");
>
>    pw.close();
>
>    Thread.sleep(10000);
>
>    resp.setContentType("text/html");
>
>    pw = resp.getWriter();
>
>    pw.println("<html><head><title>Test</title></head><body>");
>
>    pw.println("<p>Processing completed...</p>");
>
>    pw.println("</body></html>");
>
>    pw.close();
>
> Jon
>
>
>
>


RE: Possible to return multiple responses/pages for a request?

Posted by Jim Urban <ji...@netsteps.net>.
This is an unproven browser side solution which involves JavaScript and
framesets...

1.  The page that submits to the long running servlet should consists of a
frame set.  The one frame is visible and displays the page that allows the
user to input the data.  The second frame is invisible and contains a form
containing duplicate form variables.

2.  The submit button on the user input page does the following:
	1.  Copies the contents of its form variables to the hidden frame's form
variables.
	2.  Redirects the current frame to your "Processing your request, please
wait..." 	page.

3.  Your "Processing your request, please wait..." contains an "onload"
function which calls a JavaScript function in the hidden frame telling the
hidden frame to submit itself to your servlet, targeting either the visible
frame or "top" to replace the frameset completely.


I have not tried this, but I think it should work.  If you try it, please
let me know if it works.

Jim Urban
Product Manager
Netsteps Inc.
Suite 505E
1 Pierce Pl.
Itasca, IL  60143
Voice:  (630) 250-3045 x2164
Fax:  (630) 250-3046


-----Original Message-----
From: Jonathan Eric Miller [mailto:tomcat@shark.uchicago.edu]
Sent: Tuesday, August 21, 2001 4:48 PM
To: Tomcat User List
Subject: Possible to return multiple responses/pages for a request?


I'm wondering if it is possible to return multiple responses/pages from a
given request?

I have a servlet that performs some processing after a form is submitted to
it. This processing sometimes takes several seconds to complete. What I want
to do is first display a page which says "Processing your request, please
wait..." Then, after the processing is done, I want to display another page.
The second page should replace the first page in the user's browser.

Does anyone know if this is possible to do? I want to say that at some point
someone told me that you can do this with "multi-part" something-or-other?

Basically, I want to do something like the following, but, it doesn't work.

   resp.setContentType("text/html");

   PrintWriter pw = resp.getWriter();

   pw.println("<html><head><title>Test</title></head><body>");

   pw.println("<p>Please wait...</p>
");

   pw.println("</body></html>");

   pw.close();

   Thread.sleep(10000);

   resp.setContentType("text/html");

   pw = resp.getWriter();

   pw.println("<html><head><title>Test</title></head><body>");

   pw.println("<p>Processing completed...</p>");

   pw.println("</body></html>");

   pw.close();

Jon