• Post Reply Bookmark Topic Watch Topic
  • New Topic

loading strings with blanks in Textfields  RSS feed

 
scott dawson
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm in the process of converting a motif front-end to being web-enabled. I'm having a problem when a jsp loads strings that contain a blank. The actual example is more complex than the one shown below...but the example shown below works(or doesn't work) the same. I've tested this locally with Tomcat using 2 different browsers,
and I always get the same results. The string cuts off at the first blank. Any assistance would be greatly appreciated. Surely I can't be the first person to load data into a form where the data contains blanks.
Scott
Heres the code
-------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%! String noblankStr = "myjspspasmcode";
String blankStr = "my jsp spasm code";
%>
<form name="form1" method="post" action="teststrings.jsp">
<p> </p>
<table width="70%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="26%">Label Field 1</td>
<td width="74%"><input type="text" name="textfield" value=<%=noblankStr%>></td>
</tr>
<tr>
<td>Label Field 2</td>
<td><input type="text" name="textfield2" value =<%=blankStr%>> </td>
</tr>
<tr>
<td>Button </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
<p> </p>
</form>
</body>
</html>
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd try
value="<%=noblankStr%>"
and
value ="<%=blankStr%>"
as it's generally a good idea to put quotes around all HTML attribute values.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's generally a good idea to put quotes around all HTML attribute values.

Always always always always....
Repeat until you believe it.
hth,
bear
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!