You are not logged in.

akinis

Beginner

  • "akinis" started this thread

Posts: 1

Date of registration: Jul 4th 2009

  • Send private message

1

Wednesday, February 8th 2012, 4:35am

Please Help Convert java snippet for posting data to webscript to Jabaco Code

Hello all Jabaco Gurus in the house!
I need to submit data to a PHP script using the POST method but I cannot figure out for the life of me, how to change the java snippet below to work in the Jabaco enviroment.

The code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
	Dim url As URL
	
    	'URLConnection urlConnection;
    	Dim urlConnection As URLConnection
    	'DataOutputStream outStream;
    	Dim outStream As DataOutputStream 
    	'DataInputStream inStream;
  	

   	'// Build request body
    	Dim Body As String
     	Body = "email=" + URLEncoder.encode(Email, "UTF-8") + "&sub=" + URLEncoder.encode(Subject, "UTF-8") + "&mess=" + URLEncoder.encode(Message, "UTF-8")
 
   	'// Create connection
    	url = New URL("http://192.168.1.68/test/POST/post.php");
   	
    	
    	urlConnection = url.openConnection()
    	
   	'Tried to conver the code above to Jabaco the above but can't seen to do the ones below
 	
   	((HttpURLConnection)urlConnection).setRequestMethod("POST");'<--This is the real problem for me!
    	urlConnection.setDoInput(True)
    	urlConnection.setDoOutput(True)
    	urlConnection.setUseCaches(False)
    	urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    	urlConnection.setRequestProperty("Content-Length", ""+ Body.length());
 
    	// Create I/O streams
    	outStream = New DataOutputStream(urlConnection.getOutputStream())
    	inStream = New DataInputStream(urlConnection.getInputStream())
 
    	// Send request
    	outStream.writeBytes(Body)
    	outStream.flush()
    	outStream.close()



Please can the experts help me out or better yet give an alternative solution to my problem?

Thanks!

JasonS

Trainee

  • "JasonS" is male

Posts: 65

Date of registration: Feb 17th 2010

  • Send private message

2

Sunday, July 15th 2012, 12:55am

Hi akinis,

I have made a sample on how to do this (via upload.php or whatever) via a Jabaco applet. See thread FTP help?

Best Regards,
Jason

Rate this thread
WoltLab Burning Board