Class as an attribute name in JSP tag file

I just ran into an issue where I was writing a custom tag to generate a specific set of HTML elements, and wanted to be able to use CSS the same way I had before refactoring it into a tag. So, I included 'class' as an attribute in the custom tag file and deployed.
On Glassfish v3, this generated a bunch of JasperExceptions in the Javac compilation, complaining about <identifier> expected and reaching the end of file while parsing. I tracked it down, of course, to the use of 'class' as an attribute name, which was reduced to a servlet class defining:
public String getClass() {
   return this.class;
public void setClass(String class) {
   this.class = class;
}I'm curious -- which part of the process messed up here? Is "class" a valid identifier under the Java EE spec, and the translation should have used something like setClass_(String class_)? Or is it invalid, and Netbeans didn't know to mark it as an error before it tried to deploy? (And, of course, that I missed that in the spec, making it my fault.) I couldn't find anything specifically saying that reserved words couldn't be used as JSTL identifiers, so my gut is that the parser messed up. Also, I found a bug report about it for an alternate web container, but no mention of it in the bug trackers for Glassfish, Tomcat or Jasper.
Where's the blame?

stdunbar wrote:
I think that Netbeans messed up. getClass() is, of course, defined on Object and class is a Java keyword.What's to stop the compiler from recognizing that "class" would be a problem and mapping it to an alternate name behind the scenes?
This is the only documentation I turned up. Maybe this says it's invalid:
Java EE SpecThe unique name of the attribute being declared. A translation error results if more than one attribute directive appears in the same translation unit with the same name.A translation error results if the value of a name attribute of an attribute directive is equal to the value of the dynamic-attributes attribute of a tag directive or the value of a name-given attribute of a variable directive.

Similar Messages

  • Recursive calls by JSP tag files fail to compile

    We're hitting an issue with recursive calls in JSP tag files. I found one unanswered post in the General forum - [Tag Files used recursivily throws exception|https://forums.oracle.com/forums/thread.jspa?threadID=853300] - and was wondering if anyone else has hit this or knows of any work-arounds/patches or knows how to raise suspected bugs with Oracle (when you don't have an official support relationship for WebLogic)?
    Example tag file - /WEB-INF/tags/recurse/hello.tag:
    <%@ tag body-content="empty" %>
    <%@ attribute name="name" required="true" type="java.lang.String"%>
    <%@ attribute name="depth" required="true" type="java.lang.Number"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="r" uri="/WEB-INF/tags/recurse/recurse.tld" %>
    <table border="1" cellpadding="3" cellspacing="3">
    <tr>
    <td>
    Hello ${name} [${depth}]
    </td>
    <c:if test="${depth > 1}">
    <td>
    <r:hello name="${name}" depth="${depth-1}"/>
    </td>
    </c:if>
    </tr>
    </table>
    Example tld file - /WEB-INF/tags/recurse/recurse.tld:
    <?xml version="1.0" encoding="UTF-8" ?>
    <taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    version="2.1">
    <description>Library with Recursive tag</description>
    <tlib-version>1.0</tlib-version>
    <shortname>r</shortname>
    <tag-file>
    <name>hello</name>
    <path>/WEB-INF/tags/recurse/hello.tag</path>
    </tag-file>
    </taglib>
    Example jsp file - /recurse/test.jsp:
    <%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="r" uri="/WEB-INF/tags/recurse/recurse.tld" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Recursive Tag-file Test</title>
    </head>
    <body>
    <c:set var="name" value="${pageContext.request.remoteUser}"/>
    <c:set var="depth" value="${5}"/>
    <p>Welcome ${name}, here are ${depth} greetings</p>
    <r:hello name="${name}" depth="${depth}"/>
    </body>
    </html>
    The expected result from this example would be to get nested 5 HTML tables.
    The current behaviour, is the following is shown on screen when loading the test.jsp:
    Compilation of JSP File '/recurse/test.jsp' failed:
    hello.tag:15:6: Current file's JSP version conflicts with current tag "r:hello"'s.
                        <r:hello name="${name}" depth="${depth-1}"/>
    ^-----^
    hello.tag:15:6: Current file's JSP version conflicts with current tag "r:hello"'s.
                        <r:hello name="${name}" depth="${depth-1}"/>
    ^-----^
    I believe the "JSP version conflicts with current tag" message is misleading (you also get the same error referring to the tag file's folder via a tagdir reference from the JSP and defining an 'implicit.tld' which declares version="2.1"). If you take the recursive <r:hello .../> call out of hello.tag the JSP and tag file compile and function fine. I tried the work around mentioned in the forum post mentioned above, taking the recursive call out, deploying, then putting the recursive tag call back in and just updating the tag file doesn't seem to work for me.
    Using "weblogic.appc" you get a few more messages, though the issue is the same - tag file doesn't compile:
    test.jsp:15:6: The tag handler class was not found "jsp_servlet._tags._recurse.__hello_tag".
    <r:hello name="${name}" depth="${depth}"/>
    ^-----^
    test.jsp:15:14: This attribute is not recognized.
    <r:hello name="${name}" depth="${depth}"/>
    ^--^
    test.jsp:15:29: This attribute is not recognized.
    <r:hello name="${name}" depth="${depth}"/>
    ^---^
    hello.tag:15:6: The tag handler class was not found "jsp_servlet._tags._recurse.__hello_tag".
    <r:hello name="${name}" depth="${depth-1}"/>
    ^-----^
    hello.tag:15:6: Current file's JSP version conflicts with current tag "r:hello"'s.
    <r:hello name="${name}" depth="${depth-1}"/>
    ^-----^
    Happy to send this example as an ear/war for anyone that's interested.
    At this stage, WebLogic seems to be the only servlet container with this limitation.
    This has been tested with WebLogic 10.3.3.0 and 12.1.1.0.
    The context for this is that the issue is present in a (larger) enterprise application. The above simple example with recursive tags is what we have isolated as the problem.
    Although I/we may not have a support relationship for WebLogic, our clients will, so if the solution is apply an already existing patch that solution would be acceptable.

    Somethings definitely wrong with your gcc installation.
    Which gcc are you using. What output do you get from "which gcc".
    Solaris 10 ships with a gcc in /usr/sfw/bin.
    If your using a 3rd party gcc try changing your path to put /usr/sfw/bin before whereever the 3rd party gcc lives. Or just uninstall it.

  • How do I pass a local variable as a parameter to a JSP Tag File?

    I wrote a custom JSP tag file, and I want to pass a local variable to it through a parameter, like this:
    <% Integer someValue = new Integer(-5); %>
    <my:TestTag value="someValue"/>
    This doesn't work though - the result is the string someValue. Trying to do this doesn't work either:
    <% Integer someValue = new Integer(-5); %>
    <my:TestTag value="someValue"/>
    the value attribute ends up being null.
    I know I can work arount by putting the local variable in the request attributes then using ${}, but that seems like a lot of unecessary work. Does anyone know I can just pass a local variable to the custom tag through the custom tags parameter list?

    I'm far from beeing an expert, but this may be a clue (?)
    Basically, the rule is: everything you want to be considerred as Java must be in a
    JSP tag.
    As an example, think of how you would do to pass the litteral string "someValue" otherwise. Then you may imagine other related issues...

  • Error in jsp tag files with jdev 101310 and oc4j standalone10130

    Hello,
    I'm creating a simple jsp tag file that show "it´s test" and a jsp with the jsp tag file,
    the problem is:
    java.lang.NoSuchMethodError: oracle.jsp.runtime.OracleJspRuntime.releaseTagHandlers(Ljavax/servlet/jsp/PageContext;)V     at oracle.jsp._tag._tagMeta_tag.doTag(_tagMeta_tag.java:71)     at admin.applicationproperties._jspService(_applicationproperties.java:56)     [SRC:/admin/applicationproperties.jsp:10]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:270)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:42)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:204)     at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)     at com.gtsCol.bonPen.servlets.ApplicationPropertiesServlet.doGet(ApplicationPropertiesServlet.java:51)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)     at java.lang.Thread.run(Thread.java:595)
    my mail is [email protected]
    thansk for your help.

    Hola a todos,
    Estoy creando un jsp tag file que solo muestra un mensaje "Esto es una prueba" y la incluyo en una jsp normal, el problema es que no parece soportar este tipo de tags.
    El error que muestra es el siguiente.
    java.lang.NoSuchMethodError: oracle.jsp.runtime.OracleJspRuntime.releaseTagHandlers(Ljavax/servlet/jsp/PageContext;)V     at oracle.jsp._tag._tagMeta_tag.doTag(_tagMeta_tag.java:71)     at admin.applicationproperties._jspService(_applicationproperties.java:56)     [SRC:/admin/applicationproperties.jsp:10]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:270)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:42)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:204)     at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)     at com.gtsCol.bonPen.servlets.ApplicationPropertiesServlet.doGet(ApplicationPropertiesServlet.java:51)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)     at java.lang.Thread.run(Thread.java:595)
    mi correo electronico es [email protected]
    De antemano gracias por la ayuda que me puedan brindar.

  • Calling JSP Tag Files from Coldfusion

    I am trying to call a JSP Tag file from Coldfusion. I am
    getting "Unknown Tag" error.
    Here is the code I have.
    <CFIMPORT TAGLIB="/WEB-INF/lib/mtgTags.jar"
    PREFIX="mtg">
    <mtg:chooseDate appId="1" />
    mtgTags.jar contains a chooseDate.tag file.
    I know CFIMPORT statement above is working fine. Can anyone
    please tell why am I getting "Unknown Tag: chooseDate" error.
    Thanks

    Hi,
    You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
    Hope u got the answer...
    Regards
    ravi

  • Automatic Generation of classes with required attribute names

    Hi ,
    I am new to XML technologies ...I am having a problem in deciding whether I
    should use JAXB or Castor for data binding.
    The problem is the attributes I am to use are named differently as that found in
    the DTD.I have creted my own classes using the required attribute names and the
    n mapped them using the Castor mapping with the attributes.
    I was wondering how should I achieve --"automatic generation of classes" with th
    e specified attribute names?
    I understand that JAXB can be used to automatically generate classes ,but this
    uses the same default names as that of the XML file ..is there a way of forcing
    JAXB to generate classes that use my name attributes rather than that of the XM
    L dtd
    If I use Castor ..is there a way to do the same.Generate Classes with the specif
    id attributes

    Hi ,
    I am new to XML technologies ...I am having a problem in deciding whether I
    should use JAXB or Castor for data binding.
    The problem is the attributes I am to use are named differently as that found in
    the DTD.I have creted my own classes using the required attribute names and the
    n mapped them using the Castor mapping with the attributes.
    I was wondering how should I achieve --"automatic generation of classes" with th
    e specified attribute names?
    I understand that JAXB can be used to automatically generate classes ,but this
    uses the same default names as that of the XML file ..is there a way of forcing
    JAXB to generate classes that use my name attributes rather than that of the XM
    L dtd
    If I use Castor ..is there a way to do the same.Generate Classes with the specif
    id attributes

  • Using Javascript attributes in a JSP-Tag

    Hi!
    I want to submit a Javascript attribute to an embedded jsp Tag:
    <script language="JavaScript">
    function test()
         var jscriptvar= document.myform.myselection.selectedIndex;
    result = <%= jspobj.doit(jscriptvar) %>;
    </script>
    The exception is : Undefined variable: jscriptvar
    Is that possible?
    It works, if the doit-method doesn't have a parameter.
    I hope, someone can help me.
    Thanks
    Torsten

    JavaScript is executed on the client-side by the browser. The JSP code is executed on the server-side by the server and has no knowledge of JavaScript variables. You can not mix them in this manner.

  • Search strategy for JSP tag files

    Hello everyone,
    I've been trying to find a solution to this for some time, but couldn't find a clean one. Maybe somewhere here has any ideas for a solution...
    Consider a JSP taglib which is composed of hundreds of .tag files. The library is referenced in JSP using the "*tagdir*" option of the taglib directive, which simply points to /WEB-INF/tags/ (where the .tag files are located).
    Our standard server software distribution includes that tag library, as well as JSP pages that make up the server's web user interface. Those JSP pages use the taglib extensively.
    Now, we want to be able to distribute upgrades to the JSP pages and the tablib, but allow customers to easily customize some tag files without worring about loosing their changes if they apply a future upgrade.
    If it were possible for JSP pages to declare two overlapping taglib directives (same prefix) pointing to two different tagdirs, it would allow us to place our hundreds of .tag files in one "standard" directory, and allow customers to place customized .tag files in another "customized" directory. That way JSP files would always use the same prefix for our tags, but the actual .tag file inserted would be coming either from the customers's "customized" tagdir or from our "standard" tagdir (depending if they chose to override a tag with a customized version or not).
    Is this possible? How do people deal with taglib customization and maintenance issues?
    Thank you!

    Thanks for the reply!
    We use the ClickOnce smart client deployment to the user's machine and we would not want to touch/change anything on the user's machine. So, we can't rely on an environment variable being set.
    It almost seems that the DB Support Team has to not only talk to the Tech Support team and arrange for deploying the right version of the tnsnames.ora file on their users machines, but also talk to the App Deployment Team and provide the most recent version of this file to be used for deployment. So I guess if this file is checked in a code repository, the DB Support team can notify the Tech Support Team and the App Deployment Team to refresh respectively all user machines and application deployment configuration files.
    Alternatively, as one of the app deployment instructions of App Deployment team can be: "check out the most recent version of tnsnames.ora from the repository before deploying the application".
    Any thoughts?
    Thanks.
    Regards,
    gkk1969

  • JSP Tag- Passing an array of string as an Attribute

    Can I pass an array of String as an attribute to a JSP Tag? I read the specification but It does not say any thing about this.
    Thanks in Advance.

    I thought JSP tags had to deal strictly with string values?

  • Optional attributes in Tag file

    Hi,
    New to tag files here...
    Let's say I have an optional attribute defined in a tag file:
    <%@ attribute name="width" required="false" %>
    <table width="${width}">
    </table>
    How do I detect in the tag file whether that parameter is passed in or not? I want to be able to use a default value for width (say 60%) if it's not passed in, but use the value passed in if provided.
    Thanks,
    Eric.

    <c:if test="${empty width}">
      <c:set var="width" value="60%"/>
    </c:if>Or something like that...

  • Invoking getParent() from JSP tags

    Hi,
    I am writing a JSP tag that may only be invoke within a specific enclosing tag and I would like to invoke getParent() to get a reference to my enclosing tag but I can't seem to find out how to do this under JSP tag files. Any ideas?
    Gili

    one way is to set the parent tag as an attribute on the pageContext when ur processing the parent tag.
    example:
    suppose there is a parent tag and child tag nested in it......
    ParentTag.java
    public ParentTag() {
       public int doStartTag() throws JspException {
         // set the parent as a page attribute - for the nested child tag ...
         pageContext.setAttribute("someKey", this);
        return EVAL_BODY_BUFFERED;
    ChildOfParentTag.java
    public ChildOfParentTag() {
      public int doEndTag() throws JspException {
            // Get the parent tag from the page context that was set previously         
        ParentTag parent = (ParentTag) pageContext.getAttribute("someKey");
    }reg,
    sien..

  • JSP Tag -- Including a JSP fragment in a Java Tag file

    Hi all,
    I have a query regarding JSP Tag file authoring by extending the TagSupport class. I would like to know if it is possible to include a JSP file fragment inside a Java file somehow.
    Specifically, I have created a simple template tag, which adds a header and footer template to the resulting HTML page.
    <bc:template>
    Hello World!
    </bc:template>produces for example
    <html><body>
    Hello World!
    </body></html>Now I have two JSP fragment files (head.jspf and foot.jspf), and I want to do do something like
    public class HtmlTemplateTag extends TagSupport implements TryCatchFinally {
      public int doStartTag() {
        // somehow include head.jspf
        return EVAL_BODY_INCLUDE;
      public void doFinally() {
        // somehow include foot.jspf
    }Which means, I want to execute had.jspf and foot.jspf from the Java class file. I am not sure if it is even possible. If anyone can help me with this, it would be greatly appreciated.
    thanks
    nilesh

    Your intention is to put a header/footer on pages in your web application?
    There is another way to do it - specify prelude/coda jsp fragments in web.xml
    Something like the following:
    <jsp-config>
      <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <include-prelude>/WEB-INF/jspf/head.jspf</include-prelude>
        <include-coda>/WEB-INF/jspf/foot.jspf</include-coda>
      </jsp-property-group>
    <jsp-config>

  • Multiple function signatures in JSP custom tag file

    I'm writing a jsp .tag file and I've encountered the following problem. I have those two functions :
    private void iterateThroughChildElements(Element element)
         for (Iterator i = question.getElements().iterator(); i.hasNext(); )
              this.parseAndDisplay( (Element) i.next() );
    private void parseAndDisplay(Question question)
    private void parseAndDisplay(Answer question)
    (......)Both Answer and Question objects are elements but I get an error from the compiler which says that no correct signature was found for the parseAndDisplay function.
    What could be the problem ? Do I have to cast the objects according to a instanceof comparaison ??

    There was an error in my code, it is as follows :
    private void iterateThroughChildElements(Set elements)
         for (Iterator i = elements.iterator(); i.hasNext(); )
              this.parseAndDisplay( (Element) i.next() );
    }

  • Multiple function signatures in .tag file

    I'm writing a jsp .tag file and I've encountered the following problem. I have those two functions :
    private void iterateThroughChildElements(Element element)
         for (Iterator i = question.getElements().iterator(); i.hasNext(); )
              this.parseAndDisplay( (Element) i.next() );
    private void parseAndDisplay(Question question)
    private void parseAndDisplay(Answer question)
    (......)Both Answer and Question objects are elements but I get an error from the compiler which says that no correct signature was found for the parseAndDisplay function.
    What could be the problem ? Do I have to cast the objects according to a instanceof comparaison ??

    Both Answer and Question objects are elements but I
    get an error from the compiler which says that no
    correct signature was found for the parseAndDisplay
    function.The compiler is borking with the following line this.parseAndDisplay( (Element) i.next() ); You are telling it you are passing an (Element) but you have only implemented the specific function for (Question) and (Answer).
    What could be the problem ? Do I have to cast the
    objects according to a instanceof comparaison ??Use polymorphism and add the function
    private void parseAndDisplay((Element) element) {
    element.parseAndDisplay() ;
    }Then move the parse and display functionality from this class into the similar named functions in the Question and Answer classes.

  • Using scriplets in jsp-tag attribute

    I have a strange problem with a custom taglibrary that I'm trying to write.
    When I use the tag in a jsp like underneath the first outputs the right value (Welcome Hans), but the output of the second time shows: Welcome <%= test %>
    This is a part of the JSP:
    <% String test = "Hans"; %>
    <arto:hello name="Hans" />
    <arto:hello name="<%= test %>" />
    I realy don't know how to let the tag display the value of the string in my jsp.
    Can anyone give me some advice?
    Thanks,
    Hans
    The files are:
    import java.io.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    public class HelloTag extends TagSupport {
    private String name;
    public void setName(String name) {
    this.name = name;
    public int doStartTag() throws JspException {
    try {
    pageContext.getOut().print("Welcome " +name);
    } catch (IOException ioe) {
    throw new JspException("Error: IOException while writing to client");
    return SKIP_BODY;
    public int doEndTag() throws JspException {
    return SKIP_PAGE;
    The JSP:
    <%@ taglib uri="arto" prefix="arto" %>
    <%
    String test = "Hans";
    %>
    <arto:hello name="<%= test %>" />
    <arto:hello name="Hans" />
    The TLD:
    <?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/dtds/web-jsptaglibrary_1_1.dtd">
    <taglib>
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname></shortname>
    <uri></uri>
    <info></info>
    <tag>
    <name>hello</name>
    <tagclass>HelloTag</tagclass>
    <bodycontent>empty</bodycontent>
    <info>Tag with Parameter</info>
    <attribute>
    <name>name</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    </attribute>
    </tag>
    </taglib>

    In the tld for the name attribute, use
    <rtexprvalue>true</rtexprvalue>
    This specifies that the attribute value can be a run-time expression. Otherwise, the value is taken as a literal.

Maybe you are looking for

  • One wireless keyboard with two computers?

    This has already been asked probably but there is no specific area for Apple's new wireless keyboard (aluminum).. so here it goes: I have a desk with a MAC MINI and a monitor on it. (currently wired keyboard, wired mouse) Planning to buy the wireless

  • How do i access my icloud account?

    how do i access my icloud account?

  • How to play videos in a pdf

    I have a pdf with an embeded mpeg file.  It plays well in adobe acrobat and in adobe indesign but when i go to open the pdf and view it with preview the video doesn't play at all.  Any suggestions?

  • Installer failed to initialize. {CS6}

    Hello to all. I've a problem: i get this error "Installer failed to initialize. Please download Adobe Support Advisor to detect the problem." when i try to reinstall CS6 Master Collection. http://img593.imageshack.us/img593/3562/immaginegsp.png I dow

  • How to use copyPixels and mask some places?

    I've two images with the same size (49 x 90), they both are 8-bit depth. The first image has a purple backgroud color, the other one has a background color rgb(0, 255, 0) which is true green. The first image has a pixel doll with huge hair on her hea