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...
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.
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..
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....
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
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
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..
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.
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.
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.........
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...
Post by:autobot
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