Hi my name is Frederic Simard, I am whroting to you, to show you a Idea
that I got for the next JSP specification:
The Idea consit to create taglib mecanism similar to jsp to be able to
embed scrip in java code. To explain my self I have include a small
Example that will show you wath I mean. That concept is very similar
to object oriented programming because
It make possible to reuse script like a object or to do scripting inside
a object.
Fist you create a tsf (tag script file) file(something like a jsp page:
<%@ page extends="javax.servlet.jsp.tagext.TagSupport" %>
<%@ page import="javax.servlet.jsp.JspException" %>
<%!
private String name;
public void setName(String name) {
this.name = name;
}
public int doStartTag() throws JspException {
%>
<html>
<head>
<title>
<%= name%>
</title>
</head>
<body>
</body>
</html>
<%!
return SKIP_BODY;
}
%>
then you create a tld file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library
1.1//EN" "http://java.sun.com/j2ee/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>Tag Library</shortname>
<uri></uri>
<info> ... </info>
<tag>
<name>html</name>
<tagclass>there you could writhe the tsf file name </tagclass>
<bodycontent>empty</bodycontent>
<info></info>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
after it you could use the tag in a Jsp file like this:
<%@ page language="java" %>
<%@ taglib uri='../WEB-INF/taglib/demo.tld' prefix='util' %>
<util:html name="Example" />
and the generate file for the tsf file could look like this:
package ...;
import ...
public class demo extends javax.servlet.jsp.tagext.TagSupport{
public void setName(String name) {
this.name = name;
}
public int doStartTag() throws JspException {
out.write("<html><head><title>"+ name
+"</title></head><body>/body>/html>");
return SKIP_BODY;
}
private String name;
}
This is a simple example but for more complex object that tool could be
very useful to let the designer change le look
And feel easily.
ps: Excuse my English writing
Best regard