Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP body content not working for Simple Tag

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'm developing a custom simple tag. I want the tag to introduce a scripting var in the JSP page.

However, I'm struck at the web.xml element. The DD is presented here:



When I run the JSP page, I get the following error:

But, I guess JSP is a valid entry.

Any help shall be highly appreciated.
Thanks,
Reema
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, I guess JSP is a valid entry.

No it's not

Simple Tags were made to simplify the development of tags. You can make JSP pages without using scriptlets, thanks to EL, JSTL and other libraries. So there's no need to define a body as JSP with simple tags, as you don't need to use scriptlets.

To be even more precise, here is an excerpt from the JSP specification :
The body of a Simple Tag, if present, is translated into a JSP Fragment and passed to the setJspBody method. The tag can then execute the fragment as many times as needed. See Section JSP.7.1.6 for more details on JSP Fragments. Because JSP fragments do not support scriptlets, the <body-content> of a SimpleTag cannot be "JSP". A TLD is invalid if it specifies "JSP" as the value for <body-content> for a tag whose handler implements the SimpleTag interface. JSP containers are recommended to but not required to produce an error if "JSP" is specified in this case.

[ December 04, 2007: Message edited by: Christophe Verre ]
 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veree,
Thanks for the post. Simple tags are clear to me now. Thanks a ton!

However, I can use the JSP in a Classical tag...right?
I would like to share the following piece of code with you:

Tag Impl Class:

Assuming that the Boolean condition is always true.

Code fragment from TLD File:


Code fragment from the JSP View Page:


Since EL can hadle null w/o any exception, I don't get to see any value.

Your thoughts please....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic