2 Replies - 3374 Views - Last Post: 24 June 2009 - 06:58 PM Rate Topic: -----

#1 gigantic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 13-April 09

how to send data from java applet to php

Post icon  Posted 22 June 2009 - 08:28 AM

Hi,
i want to send some data(string) from my java applet to a php page when ever user clicks a button.. when user clicks another button on html page, i should be able to bring back the data and have to do some operations on that data.

i am having some public methods which returns a URLEncoded string in my applet.(basically i have a bytearray. i will compress it using zip utilities in java and then i will create a string and then send it to the php page.
)
i will call this methods in the javascript of a html page which contains the applet.
then i will post the javascript variables to a php page
it is working fine.
but as i am URLEncoding the string, the string length is more than the actual content. so i want to know whether there is any other way of doing this.
but the process should be like this.

Quote

public function should return a string in the applet
from javascript, i should call the public function.
then i should be able to post it to the php page


i tried without URLEncoding the string.
but when i send the data from php page to the applet, then the data is not coming properly . because i am using ZIP utilities, when i receive a string from php page, i have to unzip it before using it. but if i send the string without URLEncoding, then while receiving the string, at the time of doing unzip, i am getting invalid bitlength exception

i am doing stripslashes() in the php while sending data to the applet

can any one tell me is there any way otherthan URLEncoding so that i can send the actual string directly from applet-> javascript->php

Is This A Good Question/Topic? 0
  • +

Replies To: how to send data from java applet to php

#2 gigantic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 13-April 09

Re: how to send data from java applet to php

Posted 22 June 2009 - 06:38 PM

i have applet code like this.
import java.applet.Applet;
import java.awt.Graphics;
import java.net.URLEncoder;
import java.net.URLDecoder;


public class Demo extends Applet {
	public String temp = "Helloworld";
	String ENCODING = "UTF-8";
	
	public String sendData(){
		try{
		temp = URLEncoder.encode(temp, ENCODING);
		repaint();
		return temp;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public void receiveData(String data){
		try{
			temp = URLDecoder.decode(data, ENCODING);
			repaint();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public void paint(Graphics g){
		g.drawString(temp, 20, 30);
	}
}



in the above data sendData() and receiveData() are public methods which i will call in javascript. but what i want is, can i use any other methods rather than URLEncoder and URLDecoder as these methods are resulting in greater size... i want to send the Helloworld string from applet to html page and then php page.
similary whenever user wants i have to get the string from php page to javascript and then to the applet...
can any one have any ideas...
Was This Post Helpful? 0
  • +
  • -

#3 gigantic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 13-April 09

Re: how to send data from java applet to php

Posted 24 June 2009 - 06:58 PM

i tried by using javascript's URLEncoding functions after receiving data from java applet(applet sends data with out encoding). but this is also not working when i send data from javascript to applet.

can any one tell me is there any other way than using URLEncoding.. i think the browser is adding some thing to the data while transmitting data from applet to javascript and vice versa.
because of this i am unable to unzip the received data in applet.
i need some way to figure this out
can any one help me please.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1