• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP [body-content] In our TLD

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In our own custom tag, can we specify <body-content> as JSP? I encountered error in tomcat 5.0.29 if I put in JSP in my own tld. However, I checked with JSTL's tld and the tags there are all defined as JSP. Can anybody clarify this?
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. What error are you getting?
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is, I am mixing a SimpleTagSupport (supporting an outer tag) and TagSupport (supporting an inner tag).
<my uterTag>
body-content is scriptless
<my:innerTag>
body-content is JSP
</my:innerTag>
</my uterTag>

My outer tag is of <body-content>scriptless</body-content>. My inner tag is of <body-content>JSP</body-content> . And when I evaluate the outer tag's body, the following exception is thrown. I know that SimpleTagSupport cannot have body content JSP but cannot tell how this limitation would extent to the inner tag contained by it even the inner is supported by class handler where JSP is legal.


org.apache.jasper.JasperException: /WEB-INF/first.jsp(11,5) Scripting elements ( <%!, <jsp eclaration, <%=, <jsp:expression, <%, <jsp:scriptlet ) are disallowed here.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:90)
org.apache.jasper.compiler.Parser.parseElementsScriptless(Parser.java:1602)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1531)
org.apache.jasper.compiler.Parser.parseBody(Parser.java:1789)
org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1060)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1367)
org.apache.jasper.compiler.Parser.parseElementsScriptless(Parser.java:1615)
org.apache.jasper.compiler.Parser.parseBody(Parser.java:1794)
org.apache.jasper.compiler.Parser.parseOptionalBody(Parser.java:1060)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1367)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1560)
org.apache.jasper.compiler.Parser.parse(Parser.java:126)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:220)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:490)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:471)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:459)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you declared the outer tag as scriptless, you cannot have any scripting elements in its body. That includes inside the body of nested tags.
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just dont understand the rule. If the "scriptless" nature of outer tag applies to inner tag's body then if I change the inner tag's <body-content> to 'tagdependent', scriptlet in inner tag body should still cause error.

But I tested it and tagdependent inner tag worked - only when I set it to JSP that error was produced. The rule is a bit confusing.
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tagdependent means that the tag will interpret the body content, and thus it doesn't conflict with the outer tag.

Even though it is possible to nest the new and classic tag handlers as you are attempting, it's fraught with pitfalls and unless you have an insurmoutable reason to nest classic tags within simple tags, I'd either make then all use the classic handlers or make them all use the simple handlers. Otheriwse, you're going to keep running into these kinds of issues.
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic