• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Question about setAttribute

 
Freeman Fridie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this line of code in my servelet:

req.setAttribute("updatestatus","update failed");

In my JSP page where I am accessing this attribute I have the following:

<td align=left><input type=text size=50 maxlength=80 value=<%= request.getAttribute("updatestatus") %>>

When the value is displayed on my JSP form I only get the word "Update" instead of "Update Failed" . I assume the blank space is causing an issue?

How do I get around it?

thanks,
 
hatim osman
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Just like java command-line arguments, enclose your value between quotes ("") whenever there is a space between an argument, and in your case attribute. Hence the following should work without problems:

Servlet Code


JSP Code


Good Luck
Hatim Osman
SCJP, SCJD
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by hatim osman:
enclose your value between quotes ("") whenever there is a space between an argument


Always quote your attributes. Sloppy HTML will just continue to cause you needless problems.
[ August 02, 2007: Message edited by: Bear Bibeault ]
 
Freeman Fridie
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! Knew it had to be something simple.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!