File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Passing parameters to url using java.net package 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 "Passing parameters to url using java.net package" Watch "Passing parameters to url using java.net package" New topic
Author

Passing parameters to url using java.net package

kranthi chamarthi
Ranch Hand

Joined: May 08, 2007
Posts: 95
Hi,
I have two applications deployed on my server and i need to invoke a register.do class in one application from another application and need to send parameters like username,password,fullname,email,locale,country using post method. I know that using the URL class i can open the connection and open the required url....but how can i pass the parameters to it using post method??? Please advice me.
Thanks
Kranthi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42931
    
  68
Check out example e135 at http://www.exampledepot.com/egs/java.net/pkg.html It shows how to use POST programmatically in Java code, including how to send parameters.
kranthi chamarthi
Ranch Hand

Joined: May 08, 2007
Posts: 95
Thanks for that link . But still my code is nto working. Following is my code.

I have kept a print statement in multiply_method() of the action class to which arithmeticAction.do points and it is not getting printed.
kranthi chamarthi
Ranch Hand

Joined: May 08, 2007
Posts: 95
I included the code for obtaining the input stream and reading the data from the url and then the program started working. Why is this???Following is the code

This code is working only if the code that is italicized is present.

[ November 10, 2008: Message edited by: kranthi kumar.chamarthi ]
[ November 10, 2008: Message edited by: kranthi kumar.chamarthi ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

The HTTP protocol has two parts: a request and a response. If you don't try to read the response, the server may think you've dropped the connection and stop processing the request.


[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing parameters to url using java.net package