2

I have made a custom tag, to verify some user session state. But, <c:url> is not working in my custom tag body. JSP:

<a href="<c:url value="/user/logout/"/>">Logout</a> <!-- THIS IS OK! -->
<bs:ifaccount logged="true">
   <--  THIS JUST FLUSHES <C:URL VALUE=... TO WEB BROWSER -->
   <a href="<c:url value="/user/logout/"/>">Logout</a> 
</bs:ifaccount>

Tag declaration:

<tag>
    <name>ifaccount</name>
    <tag-class>bs.tags.IfLoggedTagHandler</tag-class>
    <body-content>tagdependent</body-content>
    <attribute>
       <name>logged</name>
       <type>java.lang.Boolean</type>
       <required>true</required>
    </attribute>
</tag>

Tag is implemented with SimpleTagSupport & getJspContent().invoke(null)

Kinga Odecka
  • 387
  • 4
  • 13

1 Answers1

1

Your problem is in your tag declaration:

<body-content>tagdependent</body-content>

You're specifiyng that your tag contains only text. Change it to:

<body-content>scriptless</body-content>

to allow other tags to be parsed.

morgano
  • 17,210
  • 10
  • 45
  • 56
  • ` The TLD for the class bs.tags.IfLoggedTagHandler specifies an invalid body-content (JSP) for a SimpleTag.` - project version is `Java EE 6` with `JSP 2.2` – Kinga Odecka Jul 20 '13 at 08:41
  • Scriptless is ok, so I will accept answer, but what if I want to allow scriptlets also? It is possible for SimpleTagSupport or I have to change tag implementation method? – Kinga Odecka Jul 20 '13 at 08:45
  • Ok i found that simple tags can never have scriptlets inside of them – Kinga Odecka Jul 20 '13 at 08:50
  • @KingaOdecka I investigated futher about the "JSP" value and the SimpleTagSupport, it turns out that if you want to use option "JSP" for body-content, you'll have to use the classic TagSupport and BodyTagSupport, according to [this](http://www.coderanch.com/t/521134/java-Web-Component-SCWCD/certification/body-content-JSP) – morgano Jul 20 '13 at 09:00