Forums Register Login

applet loading forever...

+Pie Number of slices to send: Send


It supposed t be like this..server send image, client display it, based on the image, client gives respond, then based on the client's respond, server send image on n on until the applicatin end.... but when i put "while" it takes forever for the applet to be loaded. it shows java loading image but the program never show up. i was wondering how i can make the program work without having to use "while" which i think makes it takes ages to load...please help me...
+Pie Number of slices to send: Send
The code snippet that you provided is not enough to answer your question.

However I think the problem very likely is that the inStream.readLine()is where your code is hanging due to the fact that there is no data to read in the stream. The readLine() is very likely blocking, waiting for data to appear. Like i said before the code is not enough to be certain about that.
+Pie Number of slices to send: Send


this is the whole code...hope you can help...
+Pie Number of slices to send: Send
i need it to be able to display image again and again each time server send a new fileName. And so i put "while" like below. But it takes forever for it to load..

+Pie Number of slices to send: Send


What exactly is this socket connecting to?
+Pie Number of slices to send: Send



this is the server code...and it communicate with New(). The thing is, when i run these code, the server is responding perfectly fine with the client. i uses system.out.println to see the outcoming.but unfortunately, the client is unable to display the next image sent by server after the 1st image. to make it work, i put "while" inside the client because i think that is where the problem coming from. but after that, the page takes forever to load..so i figure, i need to use something else other than "while" to make it work....
+Pie Number of slices to send: Send
Your applet's java console has a trace level of 1-5. Set the trace level to log all messages and check where the trace stops. Perhaps your call to the URL is blocked and is clogging the applet ? Your code was too big to go through so I am taking a hunch
+Pie Number of slices to send: Send
 

Your applet's java console has a trace level of 1-5. Set the trace level to log all messages and check where the trace stops. Perhaps your call to the URL is blocked and is clogging the applet ? Your code was too big to go through so I am taking a hunch



how to do that?im really new in java...
+Pie Number of slices to send: Send
In mozilla firefox - Tools -> Java Console
+Pie Number of slices to send: Send
im using IE and tried that consle thing and it says

Java Plug-in 1.6.0_12
Using JRE version 1.6.0_12 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\ShAr!n
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------


Loaded image: http://localhost/strawberry.jpg



this means the client-server connection is wrking. but it just takes forever to load.when i didnt use while, it loads just fine. how come when i started using while it loads forever?all i want is to make the client display the next image given by server... can you please help... do anything.. edit the code or something.. because i tried everything i know but nothing seems to work.. i really need to get this done quickly.. and i have no one else to turn to..
+Pie Number of slices to send: Send
It may or may not contribute to this problem, but in general it's a bad idea to use readLine and println with sockets: Don't println to a Socket
+Pie Number of slices to send: Send
So what do you suggest? it took me quite a while to figure what suits with what. i thought i have a perfect match. it would be great if you can suggest something for me.
+Pie Number of slices to send: Send
 

So what do you suggest?



1- If you read the article that Ulf suggested you will get the answer to that question.

2- if you look at the code in your threaded server's run method, it is waiting for applet to send it data. Your applet never sends any data to server. Server sends data to applet since it is blocked waiting for data itself. Your applet is blocked since it never receives the data it is waiting for. You need to rethink the logic here.

3- What is the point of while loop? In every iteration it is assigning a new value to image variable, and the old value is discarded without ever being used. From your description of what you are planning to do init method does not seem to be the right place for obtaining next image anyway. Didn’t you mention that the next image is sent based on client’s response? That to me translates into event listener not a while loop.



+Pie Number of slices to send: Send
i tried...i've took your advices..but i dont know where i did wrong..the program just doesnt work...i've been working on it since then but nothing seems to change...sigh.........
+Pie Number of slices to send: Send

2- if you look at the code in your threaded server's run method, it is waiting for applet to send it data. Your applet never sends any data to server. Server sends data to applet since it is blocked waiting for data itself. Your applet is blocked since it never receives the data it is waiting for. You need to rethink the logic here.



i tried using system.println to see the outcome of this program, it works perfectly fine...no problem at all...meaning the server-client code is fine...but when i try to make it display the image, it just doesnt work...so i assume the problem is with the code of displaying the image in client applet...

can you please explain

the old value is discarded without ever being used



and

From your description of what you are planning to do init method does not seem to be the right place for obtaining next image anyway.



where do you think i should put that init method...and to tell you the truth, i dont even know what exactly this init method is. all i know is i need to put the image in it to display it...its just sad...
So I left, I came home, and I ate some pie. And then I read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2033 times.
Similar Threads
Displaying an image in a servlet
applet and getCodeBase problem
Regarding java I/O
Socket Problem
Socket not connected when using host ip address.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:49:00.