I've seen this code somewhere :
<%
///// dummy tags to the browser so that connection is maintained /////////
final java.util.Vector vec = new java.util.Vector();
final java.io.PrintWriter writer = response.getWriter();
Runnable runnable = new Runnable() {
public void run() {
int count = 0;
while(vec.size() == 0) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
writer.write("<keepAlive id=\"" + count++ + "\"/>\r\n");
writer.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
Thread transectionThread = new Thread(runnable);
transectionThread.start();
///////////// End New Code to send dummy tags to browser so connection is maintained /////////
%>
<%
vec.addElement("test");
// Wait for the other thread to completed.
transectionThread.join();
%>
Does anybody know how to use it or haveanother solution ?
Actually i dont think the root cause is browser. I faced the same situation in IE too. You need to increase the transaction timeout in your application server. My deployment environment was Weblogic 8.1 /Linux. The default timeout was set as 30 secs, so my issue got resolved by changing it to 3 mins.
God know what if my transaction takes 3 mins LOL
Hi all,
I was talking about the same problem in a post recently, but i have no response yet. I think this should work but i haven't tested. First of all you should use an applet (a request from html in the browser will expire for sure if the browser has a timeout, am i wrong?) and then two things have to be done:
?In the applet use a "HttpURLConnection" and use the method "setConnectTimeout" to avoid timeout.
?Configure the server to avoid timeout. I will use Tomcat, i have to modify the http connector and change the "connectionTimeout" parameter.
This could work, but it should be tested, if any of you tries it, please feedback your results.
Thanks in advance.
> In your case you could also perform your business
> logic in a Thread apart (so you'll get an inmediate
> response from server) and then refresh from
> javascript periodically to check if the results have
> already being retreived.
It's one of the solution I was thinking, but how do I do that ? Do you have a little example of something like that ?
It would be helpful !
Thx !
I haven't any code here, but i know it can be done, i done it a year ago. The execution could have this behaviour:
1. When the user makes a request to the server from the browser, first of all check if the session holds the results requested already, if so return them, otherwise go to step 2.
2. In the server you must run your business logic in a Thread apart and inmediately return html with some javascript within to refresh the page.
3. When the business logic finishes its execution, save the
results in the session object.
4. The javascript makes a request to the server. While results aren't available, the server has to return the same page with this javascript, when we find the results in the session object then return the html with
the results.
This have some issues, if the refreshing rate of the javascript is high,
you will see your page blinking (maybe you will have to use a hidden
iframe for check for results).
Hope this is useful
I understand the way you've done it, but does anyone can explain me how to do my connection in a new Thread ?
I'm blocked with this *** problem for a while now ...
Just to remember : For Now :
1. my JSP call a servlet with info
2. In the serlet --> get the parameters, validates them and call bcDefects.vConnection() to get the data from the database. (If this request last more than 90 sec. IE expire ... grmf)
3. get back the data to the servlet and put it in a session variable cause I'll need it to draw a graphic.
4. Return to my JSP that show info and draw graphic (by calling another servlet in the SRC of a IMG tag).
I'll really be grateful if someone could help me because my expiries are soon ...
Just for information :
I found how to resolve my problem.
1. I made my class of connection extends Thread.
2. I've renamed my vConnection() as run().
3. In my servlet, I call a temporary page that run my Thread.
4. While my thread is active, my page refresh itself and when the thread is finished, I redirect to my Cyclic.jsp (display page).
Thx a lot boys to had helped me !! I'm really grateful :) !