File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Obtaining the body content of a tag as text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Obtaining the body content of a tag as text" Watch "Obtaining the body content of a tag as text" New topic
Author

Obtaining the body content of a tag as text

Marc Larochelle
Greenhorn

Joined: Sep 16, 2005
Posts: 14
Hi,
I'm trying to get the body of a custom tag as a String, make some changes in it, and then puting it back in the body. Also, I don't want the body of the tag to be executed, but just outputed as string.

Example :

-------------------------------------
<c:set var="test" value="abc" />

<tag:custom>
<c ut value="${test}" />
</tag:custom>
-------------------------------------

So in my custom tag, I'll replace the string "${test}" by "abc". So the result that I want to see in my browser is :
<c ut value="abc" />

I'm able to get the body content as a String with doAfterBody(), but it's already executed and, in the example, is alreay equals to "abc", and not "<c ut value="${test}" />"

Any idea?
[ May 07, 2006: Message edited by: Marc Larochelle ]
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Declare the <body-content> of the tag as "tagdependent" in the TLD... this prevents the container from parsing the contents but instead passes them literally.

That should do the trick.


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Marc Larochelle
Greenhorn

Joined: Sep 16, 2005
Posts: 14
It's working, thank you !
 
Don't get me started about those stupid light bulbs.
 
subject: Obtaining the body content of a tag as text
 
Similar Threads
Passing a bean property to a custom tag using JSTL
JSP fails to read POST parameters
HFSJ Mock question On page 487
mock 5 - 78% score - experiences
doubt in JSTL c:out