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 JSP [body-content] In our TLD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP [body-content] In our TLD" Watch "JSP [body-content] In our TLD" New topic
Author

JSP [body-content] In our TLD

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Yes. What error are you getting?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

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

Joined: Jan 28, 2004
Posts: 569
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP [body-content] In our TLD