My architecture is composed by: jsp-tag handler-delegate-session-entity-db I was thinking to come near to jsp2.0 (el-jstl1.2). Is possible to instance one class into Tag File without to use an scriplet and if yes how give to class instanced some parameters?
My Tag File's example is:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ variable name-given="strout" description="Parametro in uscita" variable-class="java.lang.String" scope="AT_END" %> <%@ attribute name="strin" required="true" type="java.lang.String" description="Parametro in ingresso" %> <%@ tag isELIgnored="false" %> <%@ tag import="java.util.*" %> <%@ tag import="javax.servlet.jsp.*" %> <%@ tag import="javax.servlet.*" %> <%@ tag import="test.*" %>
<% String a = (String)pageScope.getAttribute("strin"); TestDelegate testDelegate = new TestDelegate(); String str = testDelegate.getNewName(a);%>
You may be thinking about the problem not-so-correctly. If you are trying to convert an existing application from JSP 1.x to JSP 2.0, there are frequently some off-page changes that need to take place. Please read the JavaRanch Journal article that I wrote on this very subject.
To be specific, as you have discovered, scriplets are not allowed in tag files. And since your example includes a call to a method that expects a parameter, you cannot use the EL which expects bean-patterned classes.
You may need to take a step back and figure out what you are trying to accomplish and rework it. Or, if you need to do "general Java" type things in your tag, you may just need to use a Java-based tag handler rather than a tag file.