Hello Simon,
I tried to do the same thing using a Tag file instead of a Tag class. I
created a tag file named TagFileTest.tag and put it in under
/WEB-INF/tags directory with the ff content:
<%@ tag body-content="tagdependent" %>
<jsp:doBody/>
The content of the JSP file is a follows:
<%@ taglib prefix="test" tagdir="/WEB-INF/tags" %>
<test:TagFileTest>
#{'hello earth'}
</test:TagFileTest>
With this setup, the JSP is able to display #{'hello earth'}.
Without the line <%@ tag body-content="tagdependent" %> in the tag file,
the web container will throw the ff exception:
org.apache.jasper.JasperException: /1.jsp(3,2) #{..} is not allowed in
template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:711)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:940)
But this is for Tag files.
For Tag classes, you need to specify body-content of the Tag class in
your TLD file:
...
<taglib>...</taglib>
<uri>...</uri>
<tag>
<description>Any description</description>
<name>NameToBeUsedInJSP</name>
<tag-class>Fully quantified class name</tag-class>
<body-content>This is your body-content for your tag class</body-content>
</tag>
...
I used tomcat-6.0.16 and Java 1.6.
I hope this helps.
Regards
Karl San Gabriel
Simon Kitching wrote:
> Hi,
>
> This is a jasper/JSP question; I hope this is the right list for this...
>
> I am trying to write a custom JSP tag that can get its content as plain
> text.
>
> Example:
> <of:flowConfig>
> <flowCall type="example.foo">
> <param src="#{bean.property}"/>
> </flowCall>
> </of:flowConfig>
>
> I want to create a tag class for of:flowConfig which just gets the
> embedded xml text without *any* processing applied to it. I have an
> implementation that implements
> setBodyContent(BodyContent)
> and
> doApplyAfterBody(...)
> which works fine when the content does not include "#{....}". But when
> it does, I get an exception:
>
> Caused by: org.apache.jasper.JasperException:
> /tripPlanner/plane.jsp(30,31) PWC6228: #{...} not allowed in a template
> text body.
> at
> org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:49)
> at
> org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:344)
> at
> org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:156)
> at
> org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:718)
> at org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:916)
> at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2244)
> at org.apache.jasper.compiler.Validator.validate(Validator.java:1824)
> at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:168)
> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
> at
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:581)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
>
> Is there a way to tell jasper not to try to interpret ELExpressions
> within the body of a tag?
>
> Ideally I would like not to change the page, but as a last resort that
> is possible. Using CDATA doesn't work, as that is returned as part of
> the body text. Using xml comments doesn't suppress evaluation of the
> body text. Using jsp <%-- --%> comments suppresses the body-text completely.
>
> Environment:
> Tomcat 6.0.16
> java 1.6.0
>
>
> Thanks,
> Simon
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]