This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Instance class within Tag File without scriplet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Instance class within Tag File without scriplet?" Watch "Instance class within Tag File without scriplet?" New topic
Author

Instance class within Tag File without scriplet?

Angelo Giugliano
Greenhorn

Joined: Sep 22, 2004
Posts: 6
Hello to all and thousand thanks in advance

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);%>


<c:set var="strout" value="${str}"/>

----------------------------------------------------

In this way don't work. How can make?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Bartender: please move this to the JSP forum.

Welcome to the Ranch, Angelo.

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Instance class within Tag File without scriplet?