Hi BO
I tried to use res.flushBuffer() but still it prints all the contents at
once rather than step by step. Do u know the way around it.
Regards,
-----Original Message-----
From: Bo Xu [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 22, 2001 5:11 PM
To: [EMAIL PROTECTED]
Subject: Re: Updating a Servlet
"[Qari Qasim]" wrote:
> Here is a scenario:
>
> A user enters a query and submits it to servlet. The servlet prints
"thanks
> for the visit, ur query is being dealt with". At the same time the servlet
> is accessing a database and searching for user's query. Then the servlet
> updates itself with the information from the database.
>
> My real question is that how can a servlet update itself. For example,
how
> would it know that it has retrieved data from the database.
>
> Would I need to use respond.setHeader(....) method.
>
> Thanks
> Qasim
> [...]
Hi :-) I think one of the ways is like the following:
...
res.setContentType("text/html");
PrintWriter pw = res.getWriter();
pw.println("thanks for the visit, ur query is being dealt with, please
wait...");
res.flushBuffer();
try{
searchDB0(...);
pw.println(...); //output result0
res.flushBuffer();
searchDB1(...);
pw.println(...); //output result1
res.flushBuffer();
...
}catch(...){
pw.println("sorry there is a error..."); //res.flushBuffer();
}finally{
pw.println("have a nice day! haha :-) "); //res.flushBuffer();
}
pw.close(); pw=null; return;
...
>My real question is that how can a servlet update itself. For example, how
>would it know that it has retrieved data from the database.
because it is "per-service per-thread", so Servlet doesn't need to update
itself,
the following are in the same thread which is started by the container:
- pw.println("thanks for the visit, ur query is being dealt with, please
wait...");
- searchingDB0/outputingData0, searchingDB1/outputingData1...
- ...
please see the good emails about "nbio" in:
http://groups.yahoo.com/group/advanced-servlets
res.flushBuffer()(from Servlet spec2.2+) can let you output data
to a bwowser "one step by one step", but when I use a Java
Application(standalone, JDK1.3, winnt40) as the client to my Servlet,
even if I use res.flushBuffer() in Servlet-side, I still can not get data in
client-side "one step by one step" : in the beginning I can not get Any
data, and/but I get All data in the end. does anybody know why? thanks! :-)
and I guess one of the another ways is "client-auto-Refresh(pulling) +
HttpSession+..." :-)
Bo
June 22, 2001
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html