Solved

URLConnection

Posted on 2001-08-26
8
400 Views
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.
0
Comment
Question by:vinaykn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 16

Expert Comment

by:heyhey_
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)
http://yourserver.com/getquotes?23453204953204598
0
 

Author Comment

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

Thanking you..
0
 

Author Comment

by:vinaykn
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....

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:heyhey_
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.
0
 

Author Comment

by:vinaykn
ID: 6431107
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..

0
 
LVL 16

Accepted Solution

by:
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.
0
 

Author Comment

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

Expert Comment

by:heyhey_
ID: 6431185
post some sample code that reproduces the problem
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat administrtor 12 68
hibernate jars 4 57
Java basic valueOf question 1 33
Java array sort 10 31
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

756 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