facebook

tag not recognized in web.xml file!!!

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

    awebpro
    Member

    Hi,

    I have a simple web project. I was trying to test out some JSTL tags. I downloaded the proper .zip file for jstl tags and unzipped it. I installed it as follows:

    1. My web-inf/lib has jstl.jar and standard.jar

    2. I copied all the tld files into the web-inf directory. (btw, these tld files are also in the meta-inf directory. I didn’t put them there. They were auto generated. So basically I seem to have two copies.)

    3. Anyways, when I open up my web.xml file and within the web app tags do the following:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app version=”2.4″
    xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;

    <taglib — it does not recognize this tag. Why?

    </web-app>

    4. How can I add the simple ‘<taglib’ tag to the web.xml file so I can set it up as follows:
    <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri&gt;
    <taglib-location>/WEB-INF/core.tld</taglib-location>
    </taglib>

    5. Please advise. Thanks.

    #246575 Reply

    Russ
    Member

    I have the same problems. All I am trying to do is add the following basic taglib libraries

    
    <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
    

    The top portion of the web.xml file says:

    
    ?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
    

    These *.tdl are located in the WEB-INF directory, yet I am getting the same error as you:

    
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. One of '{"http://java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/j2ee":context-param, "http://java.sun.com/xml/ns/j2ee":filter, "http://java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/ns/j2ee":servlet-mapping, "http://java.sun.com/xml/ns/j2ee":session-config, "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://java.sun.com/xml/ns/j2ee":jsp-config, "http://java.sun.com/xml/ns/j2ee":security-constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/xml/ns/j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://java.sun.com/xml/ns/j2ee":ejb-ref, "http://java.sun.com/xml/ns/j2ee":ejb-local-ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://java.sun.com/xml/ns/j2ee":message-destination-ref, "http://java.sun.com/xml/ns/j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-encoding-mapping-list}' is expected.    web.xml    DBDemo/WebRoot/WEB-INF    line 27    February 11, 2006 6:51:11 AM    142
    
    

    Any help or suggestions would help us both!

    Russ

    #247540 Reply

    tolutaua
    Member

    Same problem here.

    #247546 Reply

    awebpro
    Member

    Hey guys,

    The problem is that in the new versions of tag libraries, you do not modify the web.xml file. Instead, you place the ‘<taglib’ directives inside the ‘.tld’ files and then put the tld files inside the web-inf.

    So, for example, here is a function or tag that I wrote. This file is called functions.tld and I placed it in web-inf.

    ****************************************************************
    <?xml version=”1.0″ encoding=”UTF-8″ ?>

    <taglib xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd&#8221;
    version=”2.0″>
    <description>
    Creates a new function to be called by jsp page
    </description>
    <display-name>functionsLib</display-name>
    <tlib-version>1.2</tlib-version>
    <short-name>functionsLib</short-name>
    <uri>
    http://jakarta.apache.org/functionsLib
    </uri>

    <function>
    <description>Validates a user login attempt</description>
    <name>validate</name>
    <function-class>Validate</function-class>
    <function-signature>
    java.lang.String validate(beans.LoginBean)
    </function-signature>
    </function>

    </taglib>
    ************************************************************

    The function-class is validate. Here are the contents for that:

    ********************************************************
    import beans.LoginBean;

    public class Validate {

    public static String validate(LoginBean lb) {

    try {
    if((lb.getUsername().equals(“jack”))&&
    (lb.getPassword().equals(“jill”) ))
    return “Valid Login”;
    return “Invalid Login. Please try again.”;
    } catch (NullPointerException ex) {
    return “Please login.”;
    }

    }
    }
    *********************************************************************

    IN my src, i HAVE a default package and a beans package. the Loginbean is in the beans package, the validate class is in the src package. Validate is a tag.

    And here is how I use it in a jsp page.

    **********************************login.jsp********************

    <%@ page language=”java” import=”java.util.*”%>
    <%@ page errorPage=”exception.jsp”%>
    <jsp:useBean id=”login” class=”beans.LoginBean” scope=”session” />
    <jsp:setProperty name=”login” property=”*” />

    <%@ taglib prefix=”pjbank” uri=”http://jakarta.apache.org/functionsLib”%&gt;
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <html>
    <title>Please login</title>

    <body>

    <form>
    <fieldset>
    <legend>Login Information</legend>
    <TABLE>
    <TR>
    <td><label for=”username”>User Name: </label></td>
    <td><input type=”text” name=”username” id=”username”></td>
    <TD>${login.username}</TD>
    </TR>
    <TR>
    <td><label for=”password”>Password: </label></td>
    <td><input type=”text” name=”password” id=”password”></td>
    <TD>${login.password}</TD>
    </TR>
    </TABLE>
    <p/><input type=”submit” value=”Login”/>
    <input type=”reset”/>
    </fieldset>
    </form>

    </body>
    </html>
    ************************************************

    This works. Follow the example and make necessary changes. I think it will work for you. I had to waste seven days figuring all this out and reading through several new books. Hope it saves you time. I wish these things would work like they are advertised but they don’t. And let me know how it turns out.

    #247553 Reply

    Riyad Kalla
    Member

    Answering everyone

    2. I copied all the tld files into the web-inf directory. (btw, these tld files are also in the meta-inf directory. I didn’t put them there. They were auto generated. So basically I seem to have two copies.)

    Autogenerated by what? MyEclipse doesn’t do this.

    3. Anyways, when I open up my web.xml file and within the web app tags do the following:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app version=”2.4″
    xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;

    <taglib — it does not recognize this tag. Why?

    </web-app>

    Because the format changed in Web 2.4 spec, you need to wrap them in jsp-config tags now.

    4. How can I add the simple ‘<taglib’ tag to the web.xml file so I can set it up as follows:
    <taglib>
    <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri&gt;
    <taglib-location>/WEB-INF/core.tld</taglib-location>
    </taglib>

    See my answer above, but I would point out unless you are trrying to map to custom URIs, there is no reason to remap the taglibs back to their default URIs. MyEclipse and your app server will already resolve them from your .jar/META-INF file and directory. CHeck the top of your TLD files for the default <uri></uri> tags. THen just use that in your pages, no need to enter anything in web.xml

    P.S.> Sorry I didn’t see this thread before, when you guys reply to eachother the forum software marks it as “replied to” then I don’t see it as a pending question. Sorry about that.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: tag not recognized in web.xml file!!!

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