• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

POST method

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you used an HTTP sniffer to see what's really being sent?
 
him jain
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

him jain wrote:No, sir..


Well then, now you know what the next step is.
 
him jain
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
reply
    Bookmark Topic Watch Topic
  • New Topic