473,668 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client side waiting & timeout

Hi All,

I have a servlet which is invoked from a jsp page. While the serlvet
is executing, the jsp page is waiting for the servlet to complete.
When the servlet completes, it informs the waiting jsp to redirect to
another page. The waiting jsp has implemented onload which will
redirect to the page informed by the servlet
Server : (tomcat 6.0), Browser - IE 6.0, OS - WinXP

When the servlet takes a long time to return, the page is not
redirected. It seems the browser has given up on the request or timed
out . If the servlet comes back quickly, it works fine. The problem is
seen when the servlet takes a long time to finish.

//waiting jsp code

<html>
<head>
<title>Please wait......</title>

</head>

<body style='width: 100%;' onload='dynamic Redirect();'>

<br><br>
<div class='indent'> <div id='dynamicDisp lay'</div></div>
<script>dynamic DisplayScript( 0, 'please wait' );</script<br><br>

<%
out.flush();

//wait for the serlvet to finish
String servlet_url = "/servlet/ComputeServlet" ;
request.getRequ estDispatcher( servlet_url ).include( request,
response );

%>

<SCRIPT language='JAVAS CRIPT'>

function dynamicDisplayS cript( x, info )
{
var y = 0;
var tab = FindElementById ( "dynamicDisplay " ) ;
var display_val = "<h2>"+info ;
var display_end = "</h2>";

if( Number( x ) == 0 )
{
tab.innerHTML = display_val+ "." +display_end;
y = 1;
}
else if( Number( x ) == 1 )
{
tab.innerHTML = display_val+ ".." +display_end;
y = 2;
}
else if( Number( x ) == 2 )
{
tab.innerHTML = display_val+ "..." +display_end;
y = 3;
}
else if( Number( x ) == 3 )
{
tab.innerHTML = display_val+ "...." +display_end;
y = 4;
}
else if( Number( x ) == 4 )
{
tab.innerHTML = display_val+ "....." +display_end;
y = 0;
}

var wait = 1000;
window.setTimeo ut( "dynamicDisplay Script(" + y + ", '" + info
+ "' )", wait );
}
//This is called after the page is loaded when the servet returns
function dynamicRedirect ()
{
<%
String url = ( String )request.getAtt ribute( "RedirectUR L");

%>
window.location = url;
}

</SCRIPT>

Appreciate any help

Thanks

_Pete
Jun 27 '08 #1
1 2766
Simon_21 wrote:
I have a servlet which is invoked from a jsp page. While the serlvet
is executing, the jsp page is waiting for the servlet to complete.
When the servlet completes, it informs the waiting jsp to redirect to
another page. The waiting jsp has implemented onload which will
redirect to the page informed by the servlet

Server : (tomcat 6.0), Browser - IE 6.0, OS - WinXP

When the servlet takes a long time to return, the page is not
redirected. It seems the browser has given up on the request or timed
out . If the servlet comes back quickly, it works fine. The problem is
seen when the servlet takes a long time to finish.

//waiting jsp code
Almost irrelevant.
var tab = FindElementById ( "dynamicDisplay " ) ;
Where is FindElementById () defined, and why does it have an identifier that
suggests a constructor or a factory?
if( Number( x ) == 0 )
This is pointless. Unlike Java, ECMAScript implementations implement `=='
as a type-converting comparison that implicitly does more efficiently what
you write explicitly here.
else if( Number( x ) == 1 )
[aso.]
Very inefficient and hard to maintain. Consider this instead:

if (x >= 0 && x <= 4)
{
tab.innerHTML = display_val+ "...." +display_end;
y = (x + 1) % 5;
}
window.setTimeo ut( "dynamicDisplay Script(" + y + ", '" + info
+ "' )", wait );
You might want to use the well-supported (JavaScript 1.2+, NN 3+, IE 5+)

window.setTimeo ut(
function() {
dynamicDisplayS cript(y, info);
},
wait);

instead. However you do it, don't forget to store your timeout and clear it
onunload.
<% String url = ( String )request.getAtt ribute( "RedirectUR L"); %>
Isn't that even pointless in Java? I suppose request.getAttr ibute() already
returns a reference to a String object -- why the typecast?
window.location = url;
This is not going to work, of course. The client-side script does not know
about the server-side `url' variable. You will need to do something like

<%= "window.locatio n = '" + request.getAttr ibute("Redirect URL"); + "';" %>

i.e. the server-side script generating client-side code. Don't forget to
properly escape the variable value or your client-side string literal might
break.
[...]
Appreciate any help
Redirect server-side instead.

BTW, your generated markup is not Valid. See http://validator.w3.org/
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3933
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a test on it that if the network broken at the time the client have already send the remoting request and waiting for the server, the client side will wait infinitely by default, even if i already set the executionTimeout to 90seconds in...
0
1119
by: Holger Fleckenstein | last post by:
Hi I have written a C++ server and an IDL client, that are supposed to communicate over sockets. Circumstances require, that only one client can connect at a time, and possible others are refused. So the first thing I did, was to set a short connection timeout on the client (IDL) side: socket, lun, port, connect_timeout=1
2
669
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a test on it that if the network broken at the time the client have already send the remoting request and waiting for the server, the client side will wait infinitely by default, even if i already set the executionTimeout to 90seconds in...
4
9541
by: A.M-SG | last post by:
Hi, How can I increase the HTTP Timeout value at the client side? Thank you, Alan
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8371
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8652
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.