This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes problem passing text from php to java via HTML param tag. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "problem passing text from php to java via HTML param tag." Watch "problem passing text from php to java via HTML param tag." New topic
Author

problem passing text from php to java via HTML param tag.

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
greetings, this is kind of strange. I suppose it might be a php problem, but here goes anyway.

in a php script I have a variable containing text actually is is first name last name separated by a space. That space is causing me grief

in my php code I use the echo command to create an html param tag within applet tag to pass the contents of the php variable to a java String variable. It all looks something like this...

<?php

$name = 'Fred Hamilton';

echo '<APPLET CODE="Blah.class" etc etc>';
...
echo '<PARAM NAME="name" VALUE='.$name1.'>';
...

echo '</APPLET>';

?>

now, the init() method of my JApplet class contains a line

String name = getParameter("name");

Here is the problem:

only the first name gets passed to the java variable. I tried with different strings, always the passed info stops with the first space. I tried using a string literal in my php echo statement, instead of the variable $name, and everything works fine. I edit the assignment statement for $name to remove the space, and FredHamilton gets passed.

Note that in my php script I can echo the contents of the variable to the same page that my applet code is being echoed to, and it works, so clearly it is in the passing of the variable to a java String object using param tag and getParameter that causes the string to get truncated at the first space.

Is this issue known to anyone here?

thanks.

p.s. I also posted this question in comp.lang.php
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
problem solved. The HTML used to send parameters to java was not being built properly by php.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Yeah. Wasn't quoting the attribute, right?
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
Paul Clapham wrote:Yeah. Wasn't quoting the attribute, right?


You are correct. It is interesting that it only became a noticeable problem when the contents of the php variable contained a space. I'm not certain what that is all about. I suppose HTML only requires double quotes around the text value when it contains spaces, but it does mean that there must have been extraneous material within the param tags that did not seem to interfere with the function of the tags, get my drift?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem passing text from php to java via HTML param tag.
 
Similar Threads
pass parameter from text box to applet
problem with getParameter from html page
Applet always use same Resource file
Submit dynamically created form with jQuery
call java method from javascript when using java plug-in