Forum

post method via applet

djv1rus
23 April 2012, 22:51


Hiawatha version: 7.5
Operating System: crux linux

hi !

i used wamp in windows xp before. I did some java applet,
*who send a login in an external website with socket,
*check session data returned,
*and send them in a local php script who generate a webpage.

now i installed crux with hiawatha, and it don't work anymore.

When the session datas are retuned from the applet to the post method , the php script must create a file, but do nothing.
if manually i type the local adress of the script .php in my browser, the file is created.
when i check the access logs, the post method of the applet is logged
what did i forgot please ?

i thinked it was a problem of permission, but it work when i run the php script manually
i thinked the post method is different in hiawatha, but if it is logged it works in a same way ?
i don t understand at all

thanx a lot for your help !
djv1rus
23 April 2012, 22:56
i forgot here is the php script
fwrite --->
<param name="userName" value="'.$_POST['user'].'">
<param name="latestVersion" value="'.$_POST['version'].'">
<param name="downloadTicket" value="'.$_POST['ticket'].'">
<param name="sessionId" value="'.$_POST['session'].'">

here is the socket used in the java applet

System.out.println("account name is '" + values[2] + "'");
System.out.println("version is '" + values[0] + "'");
System.out.println("downloadticket is '" + values[1] + "'");
System.out.println("sessionID is '" + values[3] + "'");

try {
String parameters = "user=" + URLEncoder.encode(values[2], "UTF-8") + "&version=" + URLEncoder.encode(values[0], "UTF-8") + "&ticket=" + URLEncoder.encode(values[1], "UTF-8") + "&session=" + URLEncoder.encode(values[3], "UTF-8");
String result2 = Util.excutePost("http://map.avetco.fr/map/test.php/", parameters);
djv1rus
23 April 2012, 23:04
i forgot the import ( import java.net.URLEncoder; )

and the function executepost

public static String excutePost(String targetURL, String urlParameters)
{
HttpURLConnection connection = null;
try
{
URL url = new URL(targetURL);
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US"); connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
StringBuffer response = new StringBuffer();
String line;
while ((line = rd.readLine()) != null)
{
String line;
response.append(line);
response.append('\r');
}
rd.close();
String str1 = response.toString();
String str1 = str1;
return str1;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
if (connection != null)
connection.disconnect();
}
throw localObject;
}
Hugo Leisink
24 April 2012, 07:58
Hiawatha doesn't support Java. I think the problem is that the Java applet is not executed.
djv1rus
24 April 2012, 09:35
hi !
the java applet is executed by the webserver of the client
the client (applet) send a post method who is logged by hiawatha
the problem is that hiawatha doesn t start the php script
Hugo Leisink
24 April 2012, 09:56
The POST method works no different in Hiawatha than in any other webserver. You said that if you enter the URL of the script in your browser's URL bar, the script works fine. That means Hiawatha works as it should. Are you sure the Java applet is sending the right request or sending at all? If Hiawatha logs nothing, I say that no request was sent...
djv1rus
24 April 2012, 11:45
problem solved :
wamp want Util.excutePost("http://map.avetco.fr/map/test.php/", parameters);
hiawatha want Util.excutePost("http://map.avetco.fr/map/test.php", parameters);
problem of slash

thanx for your help

see you
Hugo Leisink
24 April 2012, 14:27
Ah, the application uses PathInfo (path after a CGI). In that case you could also add the following configuration option: EnablePathInfo = yes.
This topic has been closed.