Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Re: Multiple response for a request and connecting to client


Message #1 by skchai@p... on Mon, 26 Mar 2001 13:49:15
Hi,

You almost ask the questions only cracker can answer. If the server-side 
can establish a connection without client-side invocation through the port 
80 and it's available in servlet API (not fire), then we can in great 
danger. 

It's impossible to establish the connection with the client again in this 
case, especially you're using session. But I have a suggestion, no 
guarantee to work.

1. Whenever you need your client to wait for the result, assign an id for 
him. This id must be unique, either a primary key of a table(database) or 
a random number.
2. Assume your result page is http://www.haha.com/test/servlet/result, 
append your id to this string as http://www.haha.com/test/servlet/result?id
3. Insert the following line to your servlet html <head> tag:
<meta http-equiv="Refresh" content="120"> 
in order to force your client browser to refresh and access your servlet 
again.
4. In your doGet method, use the following method :

String id = request.getQueryString();
...//With the id, check whether the result is ready
if (id == null) //no id, a new request.
{  ... //generate one number for him
}

if (result!=null) //result ready.
{ out.println(result); //print the result
}else {
  String url = "http://www.haha.com/test/servlet/result?" + id;
  response.sendRedirect(url);
}

The main idea is, keep the client browser refresh, stay in the session, 
wait until the result, but the client doesn't need to refresh the page 
manually. Just instruct the client to use another window to browse other 
web page.



Hope it helps ...




  Return to Index