File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes POST parameters don't appear in a PHP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "POST parameters don Watch "POST parameters don New topic
Author

POST parameters don't appear in a PHP page

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can anyone tell me why this does not work? (here is a very simplified version). There are two pages, the first one (test.html) contents a HTML form, the second one (test.php) should evaluate the parameters. I use the POST method. The parameters don't appear in the second page. Can somebody write a simple example that do it?
Very thankful,
Sam
doGet:
------------------------
OutputStream out = response.getOutputStream();
try {
URL u = new URL("http://someadr/test.html");
URLConnection uco = u.openConnection ();
response.setContentType(uco.getContentType());
InputStream in = uco.getInputStream();
DataInputStream data = new DataInputStream (new BufferedInputStream(in));
int b;
while ((b = data.read()) != -1)
out.write(b);
out.close();
}

doPost:
------------------------
OutputStream out = response.getOutputStream();
try {
URL u = new URL("http://someadr/test.php");
URLConnection uco = u.openConnection ();
response.setContentType(uco.getContentType());
InputStream in = uco.getInputStream();
DataInputStream data = new DataInputStream (new BufferedInputStream(in));
int b;
while ((b = data.read()) != -1)
out.write(b);
out.close();
Peter Kristensson
Ranch Hand

Joined: Jul 02, 2001
Posts: 118
If you use the phpinfo() function, you will see the parameters at the bottom of the page...
This probably wasn't what you were looking for though...
/Peter
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

I don't even see where you're SENDING parameters! For POST you should be writing out a stream to the PHP server. I believe the format is a line with the parameter name followed by a line with the parameter value (repeat as needed). Also you should set the content-type of the output stream.


Customer surveys are for companies who didn't pay proper attention to begin with.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks for the response. Could you tell me, how I can tell to the server, that the new request is POST. Normally, the server
gets a new request as GET.
thanks,
Sam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POST parameters don't appear in a PHP page