• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved. The HTML used to send parameters to java was not being built properly by php.
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. Wasn't quoting the attribute, right?
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!