Link to home
Start Free TrialLog in
Avatar of vinaykn
vinaykn

asked on

URLConnection

I am using urlconnection class for getting realtime quotes for my Stocks Web Application. I set keep-alive connectin, the back-end will keep sending realtime quotes to application. But i am getting problems in different kinda browsers. Internet Explorer not able to referesh the screen according to my request. Netscape 4.7 is refreshing but not perfectly. Netscape 6.1 which is using Java plug-in, is seems to ok.  

Earlier when i was using sockets i dont get any problem. With same peach of code, just changing after to URLConnection it start giving problems...

Can anyone guide me in this regard. Is it problem with protocol or url connection or my browser...What could be the problem.
Avatar of heyhey_
heyhey_

> not able to referesh the screen according to my request.

I suppose that you are receiveing the same data upon each request, because somebody (JavaVM / browser / proxy) caches the answer.

I would suggest you to use unique URL for each request (appending random number for example)
http://yourserver.com/getquotes?23453204953204598
Avatar of vinaykn

ASKER

I am not able open the url sent by you. Is it correctly typed? can you check for me?

Thanking you..
Avatar of vinaykn

ASKER

Whenever i am pressing a button to refresh(or to sort the stocks) i will send a message to back-end. Back-end will send a message, basing on that message my application will refresh and sort the data which is stored in a vector.

Now the problem is, when i am Netscape, its sending message to back-end and also getting response from back-end, basing on that its doing refreshing or sorting perfectly.

When i am using Netscape, its sending message to back-end. Back-end also responding immediately sending data.  But, my browser not able to read it immediately....If i press continuiously three or four times, its reading all three or four messages from back-end and then doing processing?

Is it any problem with browser stream handling, howcan i read immediately whenever a back-end send something....Is it reading problem or any cache problem...

Can you help me in this way....

> I am not able open the url sent by you. Is it correctly typed?

it's just a sample URL that uses random suffix

> its reading all three or four messages from back-end and then doing processing?
> Is it reading problem or any cache problem...

I don't know what your backend is doing. the ONLY POSSIBLE difference between socket based and http based protocols is caching that may be done transparently from some proxy.

add some additional System.out.println()s to track the problem.
check if backend receives the messages.
check when exactly client receives the answer and what's that answer.
Avatar of vinaykn

ASKER

heyhey,

While using sockets i used BufferedReader to read input from back-end.  It didnt give any problems while reading data from back-end and processing and refreshing.

When i encounter about problem, that too only, in Internet explorer, i changed it to DataInputStream.  Now its working fine in both browsers...

Why this BufferedReader gave me problems when i changed my socket connection to URLconnection.

Thanks again..

ASKER CERTIFIED SOLUTION
Avatar of heyhey_
heyhey_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinaykn

ASKER

why only 'sometimes'? can you give me any idea this. I think this buffering only gives me problems...
post some sample code that reproduces the problem