facebook

JSP Compilation error with Struts taglib declarations

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #249883 Reply

    Max Vilner
    Member

    I get this error:

    “Attempt to redefine the prefix bean to http://jakarta.apache.org/struts/tags-bean, when it was already defined as /tags/struts-bean in the current scope.”

    when I try to point jsp to the Struts 1.2 tld’s defined in my web.xml like this:

    <%@ taglib uri=”/tags/struts-bean” prefix=”bean” %>
    <%@ taglib uri=”/tags/struts-html” prefix=”html” %>
    <%@ taglib uri=”/tags/struts-logic” prefix=”logic” %>
    <%@ taglib uri=”/tags/struts-tiles” prefix=”tiles” %>

    The same error also occurs when I generate the JSP using Struts 1.2 template which gives different web uri. Can anyone please shed some light on this? Thanks.

    #249919 Reply

    Riyad Kalla
    Member

    Is this an error marker in a JSP page somewhere or are you seeing it somewhere else? Can you paste the full <taglib> section of your web.xml file for me, and also paste the top of a JSP file you are having a problem with.

    #250041 Reply

    Max Vilner
    Member

    This is an error marker on JSP page. What’s weird is that I have another page with the same taglib reference and it’s fine. Here’s the problem JSP:

    
    <%@ page language="java" pageEncoding="UTF-8"%>
    
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
    <%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html:html locale="true">
    <head>
        <%String path = request.getContextPath();
            %>
        <html:base />
        <title>Manage Application Groups</title>
    </head> 
    

    And this is web.xml:

    
     
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-nested.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-tiles</taglib-uri>
        <taglib-location>/WEB-INF/tlds/struts-tiles.tld</taglib-location>
      </taglib>
    </web-app>
    

    Thanks for your attention to this, Riyad.

    Max.

    #250044 Reply

    Riyad Kalla
    Member

    Max,
    This all looks correct. Try and clean/rebuild your project and restart MyEclipse if necessary to rule out TLD cache issues.

    Also, from the looks of your web.xml file I am assuming the top of the file is referencing the Web 2.3 DTD and not the Web 2.3 schema, is that correct?

    Does autocomplete work? And is this error marked in the left margin, right margin or both?

    #250049 Reply

    Max Vilner
    Member

    Yes, web.xml is referencing dtd. Autocomplete works. I did all you recommended but it did not help. The errors are marked on both margins and in the Problems view. However the markings on the left are off as well as the line # references in the Problems.

    Here’s some info that might help: I created the project from existing source with preexisting web.xml and one JSP that references the taglibs according to web.xml definition. When I added Struts support, I left the default version which is Sruts 1.1. Later I generated a JSP using MyEclipse Struts 1.1 template and it generated the references as follows:

    
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    

    I still have that page in the project. Then I generated another page using Struts 1.2 template and got an error with taglib references. So removed Web support from the project, readded it, and added Struts 1.2 support, but that didn’t help. So I changed the taglib references to the web.xml definitions, but that didn’t help either.

    I hope that’s clear enough and will be helpful for troubleshooting. Thanks.

    #250052 Reply

    Riyad Kalla
    Member

    I can reproduce this, but it’s because the struts wizard is not overwriting your Struts 1.1 JARs with the 1.2 JARs, this is to avoid project corruption. So if you open your struts.jar/META-INF.tlds/struts-html.tld file, notice it’s still the 1.1 taglibs, not the 1.2 taglibs.

    Try restarting using the -clean command line argument and check your old project. If that still doesn’t work, export your project to a zip (File > Export > To Archive) and send it to support@genuitec.com ATTN Riyad with a link to this thread so I know why I’m getting it.

    #250060 Reply

    Max Vilner
    Member

    – clean helped. I just had to manually rerun MyEclipse validation on the JSP’s. Thanks a lot. You’ve been very helpfull.

    #250062 Reply

    Riyad Kalla
    Member

    I’m glad it’s working now.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: JSP Compilation error with Struts taglib declarations

You must be logged in to post in the forum log in