jsp custom tags, can we have objects within the body?

O

ogenium

Hi ,
I was wondering if it possible to have java objects within the body of
a custom
tag.

e.g <mytagslib:myObjformatter><%=MyRecordObj
%></mytagslib:mycObjformatter>

The custom tag in this case would extract the fields inside MyRecordObj
and format them in an appropriate manner inside an html table;

thanks
 
J

John C. Bollinger

Hi ,
I was wondering if it possible to have java objects within the body of
a custom
tag.

e.g <mytagslib:myObjformatter><%=MyRecordObj
%></mytagslib:mycObjformatter>

The custom tag in this case would extract the fields inside MyRecordObj
and format them in an appropriate manner inside an html table;

The JSP fragment you present will not do what you hope. It will cause
the String value of the object (obtained via its toString() method) to
be handled by the custom tag body -- not the object itself. However,
given suitable declarations, you _can_ deliver an object to a tag
handler via a tag attribute, or you can bind the object as a page (or
request / session / application) attribute apprise the handler of the
attribute name to use. You can even expose the tag handler object as a
JSP scripting variable within its body, thereby allowing scriptlet code
to invoke a method on it to specify the object to work on.

So no, you cannot do exactly what you asked, but you can accomplish what
you say you want to do via other avenues.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top