I'm not an expert on JSP 2.0 tags, but I'll pass on a little of what
I know. Without knowing exactly what you are looking for... here
is a rough example...
// by including this line you may have one tag use another tag.
you will need other taglib tags for any other tag lib you use (like the
standard taglib)
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
// each variable you use in the tag is defined like this <%@
plus the variable name and then %>. Also, if you change the
number of attributes you will
// need to update the TLD (if you use it, you don't for simple tags),
and probably restart your servlet engine.
<%@ attribute name="welcome" %>
<%@ attribute name="value" %>
<%@ attribute name="title" %>
<%
// you may use java directly within the tag...
if (value == null || value.length () == 0)
{
return;
}
%>
<!-- tag vars are included using JSP syntax (this appears to be different
in JSP 2.0 than in earlier versions of JSP... others may comment)
So, <%= plus the var name and
%> to end it. In previous versions and Apache Tomcat examples, the
syntax was ${ var } .
-->
<h1><%= title %></h1>
<p><%= welcome %>
<!-- in addition to this, what happens in the <%= can be a method
call (without the ending semicolon) or other complex Java _expression_.
But the result of that method call or _expression_ must return a non-void
value.
-->
<br>value.myValue = <b><%=
value.getMyValue () %></b>
<a href=""invalid") %>">
<font size=1 > Create
a new Value </font>
</a>
<a href="">
<font size=1 > Create
a new Value </font>
</a>
</p>
Obviously, you might need to remove the comments and adjust this for your application for this to work.
Frank
Maya menon wrote:
Hi all,I have a jsp page which shd display dynamic data based on different values of one field.
As an example : I have a field "myData".if myData has value "a" , the jsp should display,
a header , a. Two links like "Create new a", "Search for a" and a.myValue, another value.if my Data value is b, jsp should display header b, two links for b and the myValue for bif myData value is c, similiar display.How can I write a dynamic tag ?Any examples.. pleaseThanks
Shreya
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
