*
The moose likes Sockets and Internet Protocols and the fly likes POST method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "POST method" Watch "POST method" New topic
Author

POST method

him jain
Ranch Hand

Joined: Feb 05, 2010
Posts: 56
On sending side, I have written this code:

String message= "name="+str1+"%21";
out = hc.openOutputStream();
out.write(message.getBytes());
String message1 = "age="+str2+"%21";
out.write(message1.getBytes());
String message2 = "place="+str6+"%21";
out.write(message2.getBytes());
out.flush();

and on receiving servlet i have written:
String m1 = request.getParameter("name");
String a1 = request.getParameter("age");
String p1 = request.getParameter("place");
String mob_no = "Received mobile: '" + mobile + "'";
System.out.println(m1);
System.out.println(a1);
System.out.println(p1);

but nothing is getting stored in p1 and a1.
the whole data is getting stored in m1 only.
can you suggest me. why?how?
I want that data to be stored in p1 and a1 diffferently.
Waiting for a quick reply.


--Himanshu Jain
http://jainhim.blogspot.com/
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
I believe that the POST parameters are expected to be one per line so add a crlf to each message.

Bill
him jain
Ranch Hand

Joined: Feb 05, 2010
Posts: 56
Sir,

I have added "\r\n" to each message but still nothing got stored in the last two strings.
String message= "name="+str1+"\r\n";

Still only first string has all the values and the last two strings (a1 and p1) are null.
Please solve my problem.
I have been searching for a solution from a long time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Have you used an HTTP sniffer to see what's really being sent?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
him jain
Ranch Hand

Joined: Feb 05, 2010
Posts: 56
No, sir..
actually message 1,2 and 3 strings all are getting stored into string str1 :
String m1 = request.getParameter("name");
I want them to store them individually but they are not even if i have appended "\r\n" to each string.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42935
    
  68
What Bear was getting at is that you should use an HTTP sniffer to compare the difference between a functioning POST to some web site and your POST. That should provide a clue what you need to change.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

him jain wrote:No, sir..

Well then, now you know what the next step is.
him jain
Ranch Hand

Joined: Feb 05, 2010
Posts: 56
ya!!
i got it.
I'll get back to you if any problem comes after using it or if i am not able to get.
If still anyone has any suggestion, do psot your reply.
Thanks..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POST method