facebook

Error in web.xml

  1. MyEclipse Archived
  2.  > 
  3. Web Development (HTML, CSS, etc.)
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #259180 Reply

    cpyong27
    Member

    Hi,
    My web.xml looks like below, but I am getting an error at the line where <taglib> is. Anyone knows what has gone wrong? I really have fmt.tld in the /WEB-INF/tld directory.

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

    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221;
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″
    xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>
    org.apache.struts.action.ActionServlet
    </servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>debug</param-name>
    <param-value>3</param-value>
    </init-param>
    <init-param>
    <param-name>detail</param-name>
    <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <taglib>
    <taglib-uri>/WEB-INF/fmt.tld</taglib-uri>
    <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
    </taglib>

    </web-app>

    #259182 Reply

    Riyad Kalla
    Member

    One of the changes with the Web 2.4 specification is tha tyou now need to wrap your taglib tags inside of <jsp-config> tags. Give that a try.

    #259214 Reply

    cpyong27
    Member

    Thanks for your prompt reply. The error is now gone, but I still cannot get it to load the keys defined in ApplicationResource.properties though I have defined <message-resources parameter=”com.cmr.struts.ApplicationResources” /> in struts-config.xml. For example, my user login page which consists of simply 2 labels (for stating name & password), 2 text boxes (for name & passowrd input) and a login button, does not display the correct text defined in ApplicationResources.properties. This is the code of my user login jsp:

    <%@ page language=”java”%>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean&#8221; prefix=”bean”%>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-html&#8221; prefix=”html”%>
    <%@ taglib uri=”/WEB-INF/fmt.tld” prefix=”fmt”%>

    <html>
    <head>
    <fmt:setBundle basename=”ApplicationResources” />
    <title>JSP for UserLoginForm form</title>
    </head>
    <body>
    <html:errors property=”login”/>
    <html:form action=”/userLogin” focus=”userName”>
    <table align=”center”>
    <tr align=”center”>
    <td><H1><fmt:message key=”login.message” /></H1></td>
    </tr>
    <tr align=”center”>
    <td>
    <table align=”center”>
    <tr>
    <td align=”right”>
    <fmt:message key=”login.username”/>
    </td>
    <td align=”left”>
    <html:text property=”userName” size=”15″ maxlength=”15″/>
    <html:errors property=”userName”/>
    </td>
    </tr>
    <tr>
    <td align=”right”>
    <fmt:message key=”login.password”/>
    </td>
    <td align=”left”>
    <html:text property=”password” size=”15″ maxlength=”15″/>
    <html:errors property=”password”/>
    </td>
    </tr>
    <tr>
    <td colspan=”2″ align=”center”>
    <html:submit>
    <fmt:message key=”login.button.signon”/>
    </html:submit>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>

    </html:form>
    </body>
    </html>

    and this is the content of the ApplicationResources.properties:

    # Resources for parameter ‘com.cmr.struts.ApplicationResources’
    # Project P/CMROnline

    #login page text
    login.message=Welcome to CMR Online
    login.username=User ID:
    login.password=Password:
    login.button.sigon= Log In Here!

    ———————————————

    I hope u could help me again. Appreciate that.

    #259223 Reply

    Riyad Kalla
    Member

    Your basename is wrong, it has to be the full package: com.cmr.struts.ApplicationResources

    #259228 Reply

    cpyong27
    Member

    Hi Riyad,
    Thanks again for your prompt reply. It works now. The error was due to my lack of understanding of “basename”. You are really my hero!!!
    Thank you very much!!!

    Regards,
    Jacob

    #259232 Reply

    Riyad Kalla
    Member

    I’m glad it’s working, it’s always the little things that bog us down isn’t it?

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Error in web.xml

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