Month: November 2012

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Posted on Updated on

According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Keywords:
Compile JSP tomcat JSTL error “According to TLD or attribute directive in tag file, attribute value does not accept any expressions”

Problem:
Compile error from tomcat when it encounters a JSP: “According to TLD or attribute directive in tag file, attribute value does not accept any expressions”

Solution:
For some reason the JSP is using the 1.2 JSP (and 1.0 JSTL) and EL expressions aren’t understood. There’s a lot of hits on the web for this but in summary there are 2 important things to do to ensure you’re getting the right version of the spec:

  1. Reference the correct servlet specification in your deployment descriptor:
    <?xml version="1.0"?>
    <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">
  2. Reference the correct JSTL uri in your JSP:
    change
    <%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%>

    to

    <%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>

Notes:

What Specification goes with what?
Web-app(deployment schema) 2.3 2.4 2.5
http://java.sun.com/dtd/web-app_2_3.dtd http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
Servlet 2.3 2.4 2.5
JSP 1.2 2.0 2.1
JSTL(core uri reference) 1.0 1.1 1.2
http://java.sun.com/jstl/core http://java.sun.com/jsp/jstl/core http://java.sun.com/jsp/jstl/core
Tomcat 4.x 5.x 6.x
WebSphere 5.x 6.x 7.x (?)


Invalid servlet mapping in tomcat

Posted on Updated on

A common exception ,”Invalid <url-pattern> servlet mapping” when deploying application server in tomcat. 
The url-pattern specification:
  • A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
  • A string beginning with a ‘*.’ prefix is used as an extension mapping.
  • A string containing only the ’/’ character indicates the “default” servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only.

invalid web.xml:

<servlet>    <servlet-name>remoteLoggingServlet</servlet-name>    <servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>  </servlet>    <servlet-mapping>    <servlet-name>remoteLoggingServlet</servlet-name>    <url-pattern>mweb/remote_logging</url-pattern>  </servlet-mapping>   

valid web.xml:

 <servlet>    <servlet-name>remoteLoggingServlet</servlet-name>    <servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>  </servlet>    <servlet-mapping>    <servlet-name>remoteLoggingServlet</servlet-name>    <url-pattern>/mweb/remote_logging/*</url-pattern>  </servlet-mapping>