Solved

URLConnection

Posted on 2001-08-26
8
402 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
Industry Leaders: 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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

707 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