1

I connected to servlet from swing using HttpURLConnection. I did not understand this code:

 DataOutputStream wr = new DataOutputStream(
 connection.getOutputStream()); //connection is obj of HttpurlConnection class.

 wr.writeBytes(un);//un contains username retrieved from textbox from the swing 
 wr.flush();
 wr.close();

What is the way to read values in the servlet, so that I can do further process (like inserting into database etc..)

Is there any method other than above method or can I get values through request object?

yatskevich
  • 2,085
  • 16
  • 25
user1168647
  • 247
  • 1
  • 3
  • 11
  • Didn't [this](http://stackoverflow.com/questions/9090580/sending-data-from-swing-to-servlet) help you – jmj Feb 01 '12 at 10:39

1 Answers1

1

You'll need to decorate the request input stream with a DataInputStream:

DataInputStream dataIn = new DataInputStream(request.getInputStream());
String un = dataIn.readUTF();
David Grant
  • 13,929
  • 3
  • 57
  • 63