How to display <bean:write> in text field
Hi there
I am trying to display a return bean:write value in a text field, e.g;
<html:text property = "firstName" value = "<bean:write name='userCredentials' property = 'firstName'/>"/>
It should display as a firstName such as "John". However, it shows "<bean:write name='userCredentials' property = 'firstName'/>" in the text field instead.
I am new to Struts, please someone help me. Thanks
Ming
> Hi there
>
> I am trying to display a return bean:write value in a
> text field, e.g;
>
> <html:text property = "firstName" value > "<bean:write name='userCredentials' property > 'firstName'/>"/>
You cannot use tags this way. You have at least two alternatives:
1) Use a scripting expression for the value of html:text
<jsp:useBean id="userCredentials" class="your.bean.CredentialsClass" scope="session" />
<html:text property = "firstName" value ="<%=userCredentials.getFirstName()%>" />
or
2) Use EL-aware version of the tags.
You'd be able then to write something like
<html-el:text property = "firstName" value ="${userCredentials.firstName}" />
See also:
http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html
http://www.exampledepot.com/egs/javax.servlet.jsp/usebean.jsp.html
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html
http://struts.apache.org/1.x/struts-el/tlddoc/html/tld-summary.html
http://struts.apache.org/1.x/struts-el/tlddoc/index.html