wood burning stoves 2.0*
The moose likes JSP and the fly likes jsp:getProperty name shows only first word in string. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:getProperty name shows only first word in string." Watch "jsp:getProperty name shows only first word in string." New topic
Author

jsp:getProperty name shows only first word in string.

Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
Hi,

The lastName property is "Smith Jones", but only "Smith" is displayed.

When I view the browser source I see

so in html the quotes are missing as in value="Smith Jones"

When I save the html and change it to

"Smith Jones" is displayed properly.

Lines 26 and 27 contain is where the issue is.

I have also tried using
value='<jsp:getProperty name="employee" property="lastName" />'
that I found when googling jsp:getproperty truncates bean data at first blank.

How do I get the quotes into the property?

Thanks,

Lou


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

The highest level observation is that using scriptlets and antiques like <jsp:getProperty> is about 10 years out of date.

But the easy answer is: value="<jsp:getProperty name="employee" property="lastName"/>">

The quotes should be in the template text, not in the value of the property.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lou Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
I suppose it would help too if I change the correct source file.

Doh!

No Emoticons for slapping myself in the forhead.

The highest level observation is that using scriptlets and antiques like <jsp:getProperty> is about 10 years out of date.


So Bear, what is the 2011 way?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Since the inception of JSP 2 in 2002, the JSTL and EL should be used in place of scriptlets and the old property actions.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp:getProperty name shows only first word in string.
 
Similar Threads
Transfer data from Java beans to portlet
Problems with bean example
JSP session
J2EE and Servlets
Problem regarding redirected error message