Posted on 2001-08-26
Last Modified: 2012-05-04
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.
Question by:vinaykn
  • 4
  • 4
LVL 16

Expert Comment

ID: 6428781
> 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)

Author Comment

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

Thanking you..

Author Comment

ID: 6430757
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....

LVL 16

Expert Comment

ID: 6430915
> 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.
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.


Author Comment

ID: 6431107

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..

LVL 16

Accepted Solution

heyhey_ earned 50 total points
ID: 6431132
I do not have your code, so I cannot give you perfect answer, but generally speaking 1. BufferedReader works with Unicode chars (2+ byte sequences) / not bytes and 2. BufferedReader 'sometimes buffers' the incoming data :)

best solution is to read the data directly from the InputStream.

Author Comment

ID: 6431178
why only 'sometimes'? can you give me any idea this. I think this buffering only gives me problems...
LVL 16

Expert Comment

ID: 6431185
post some sample code that reproduces the problem

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now