0

Environment:

  • Tomacat 8
  • Servlet 3.1
  • JSP 2.3
  • Java 1.7.0_79
  • Maven
  • Struts2

Why doesn't work EL in this JSP file?

el.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    ${5+3 }
    ${5+hola }
    <s:url action="registerInput" var="registerInputLink" />
    ${registerInputLink}
</body>
</html>

and what I see in the web page is:

${5+3 } ${5+hola }  ${registerInputLink} 

web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
    <display-name>Archetype Created Web Application</display-name>

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>
Joe
  • 7,511
  • 17
  • 56
  • 101

1 Answers1

0

The problem seems to be with your web.xml. You have to add some namespaces to the web-app tag

web.xml header for servlet 3.1

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
        http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">
    <!-- Config here -->

You can find the correct namespaces for your Tomcat instance in the example apps that come with a Tomcat install.

Joe
  • 7,511
  • 17
  • 56
  • 101
underdog
  • 4,368
  • 8
  • 40
  • 85