aspose file tools*
The moose likes Applets and the fly likes URLConnection timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "URLConnection timeout" Watch "URLConnection timeout" New topic
Author

URLConnection timeout

f jimenez
Ranch Hand

Joined: Mar 14, 2007
Posts: 30
hello guys im back.

i have an applet that connects to a servlet in the server. the connection used is URLConnection. now i want that if this applet can't connect/can't get data from the server at a given time, the user has the option to abort connection or continue...

how do i do this using URLConnection?

codes will be very much appreciated

thanks...


if you can't be the sun, be a star...<br />もし たいように なれないたら ほしに なれ。
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
URLConnection has a few methods with "timeout" in their names; check the javadocs what exactly they do.

Alternatively, you can run a Timer in the applet which after a certain amount of time fires, and if the connection hasn't returned anything by that point, do something about it.


Ping & DNS - updated with new look and Ping home screen widget
f jimenez
Ranch Hand

Joined: Mar 14, 2007
Posts: 30
thanks ulf.

how can you do the second option? pls help...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Have a look at the java.util.Timer and TimerTask classes.
f jimenez
Ranch Hand

Joined: Mar 14, 2007
Posts: 30
thanks...

i just have another question though. what exactly does timeout do? does the connection stop when timeout is fired?

how can i reconnect it? to reconnect it, does it mean i have to make the same process again?

thansk a lot.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
what exactly does timeout do? does the connection stop when timeout is fired?

Yes, it's terminated.
how can i reconnect it?

You need to make a new connection, in the same way you did the first one.
f jimenez
Ranch Hand

Joined: Mar 14, 2007
Posts: 30
yes, thats exactly what i did... thanks a lot...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLConnection timeout
 
Similar Threads
how to read a file on server from a applet
How applet can be used to browse for all files in a folder without refresing the page?
why my applet is not establishing URLConnection with Server
How can I close a URLConnection?
Had to back up to 1.3.1_02