• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

body-content JSP not working

 
Ranch Hand
Posts: 220
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
https://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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your valuable explanations
I got it...


 
You've gotta fight it! Don't give in! Read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic