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

body-content JSP not working

 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a TLD file under WEB-INF folder

The content of tld is





And I have a jsp pages with content




When I tried this code the first tag content with text works on the other hand the second tag gives exception like below... I would like to use any JSP in my tag body!!


org.apache.jasper.JasperException: /jsppages/tagsuse.jsp(27,1) The TLD for the class com.tt.taghandlers.SimpleExWithBody specifies an invalid body-content (JSP) for a SimpleTag.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch

[ December 18, 2008: Message edited by: Anut Walidera ]
[ December 18, 2008: Message edited by: Anut Walidera ]
 
Matteo Palmieri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

as the error message says, you cannot include scripting code in the body of a SimpleTag. This is the reason why the following line in the TLD is not valid:

<body-content>JSP</body-content>

If you really need to use scripting code, then you should go for the Classic Tag (by implementing the javax.servlet.jsp.tagext.Tag interface).
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use scripting inside the tag's body for SimpleTag implementations, basically this is because the body of a Simple Tag Handler is represented by JspFragment which does not support scriplets, therefore the <body-content> may not be "JSP"

Here are a few resources to help you understand why:
http://www.coderanch.com/t/92972/java/SimpleTag-body-content
http://www.orionserver.com/docs/tutorials/taglibs/16.html#what
 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your valuable explanations
I got it...


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic