struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Struts Wiki] Update of "StrutsTags" by MichaelJouravlev
Date Fri, 14 Oct 2005 20:44:22 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.

The following page has been changed by MichaelJouravlev:

New page:
This page contains FAQ on Struts, Struts-EL, JSTL and Ajax tags. The separation between these
categories is rather fluid, because it is possible to mix and match tags, for example to use
JSTL tags or scriptlets within Struts tags. Therefore, please look in all categories.

== Struts tags ==

=== NPE when accessing value using scriptlet ===
Q: I use the following code in a jsp:

 <logic:present name="person">
   <html:text property="name" " value='<%= person.getName() %>'/>

If 'person' is not present <%= person.getName() %> is compiled and I get
this error: membreLIFL cannot be resolved

If i use this code:

 <logic:present name="person">
   <input type="text" name="name" 
          value="<bean:write name="person" property="name"/>"

No problem. How can i use the html:text tag?

A: JSP scriptlet is a regular Java code, which calls a method on "person" object. If "person"
object is not defined, an NPE is generated. 

Choice 1: If you use JSP 2.3 + Struts-EL or JSP 2.4, you can use the following syntax to access
"name" property:
 <html-el:text property="name" value="${}" />
JSTL does not throw NPE if you accessing a property of non-existing object.

Choice 2: If a Struts tag defines "value" attribute, it is possible to use either this attribute
or text element of a tag. The following definitions are equivalent:

 <html:text property="name" value="someData"/>


 <html:text property="name">

== Struts-EL tags ==

== JSTL tags ==

== JSP scriptlets ==

== Ajax Tags ==

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message