• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Question about setAttribute

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! Knew it had to be something simple.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic