views:

106

answers:

2

I need to write a simple servlet which will be the client, and it should be sending some simple strings to server written in java. However I have a problem and I don't know how to solve it. I was trying to put the code in servlet methods but it ain't working. Here is the code which works great in my standard (non servlet) java client: http://pastebin.com/m6503d49f

Can anybody help me, how to solve the problem. By the way this is for my school project.

A: 

Does the client code work when running as a stand alone application invoked from the command line?

Thorbjørn Ravn Andersen
A: 

Yeap, It works, I solved the problem by the way, and I don't know what was the problem, I defined new method inside my servlet with same code and everything works fine, when I call that method in doPost or doGet but If I place code from my new method to doPost or doGet I have the same problem, so I will live it, because it works, tnx for your time

Splendid
maybe you could share the source of the servlet?
kd304
No problem, Here it is: http://pastebin.com/d3948893aBut I don't know why do u need it :P
Splendid
Just two remarks: (1) You still have a <code>BufferedReader input = new BufferedReader(new InputStreamReader(System.in));</code> in your code which is unnecessary in servlet. (2) You are not closing the socket/streams. Maybe you left the infinite loop or the system.in readLine() from your client code?
kd304
I will follow your advices and will post another question if that's necessary. This is just for school project and Java is not my primary language if u know what I mean :DTnx for advice once again!
Splendid