jstl - EL expressions not evaluated in JSP -


there's small problem servlets/jsp web application. i'm trying use jstl in jsp page. when use tag example:

<c:out value="${command}"/> 

it shows me

${command}  

in browser instead of parameter 'command' value. i'm using maven (and guess problem here). here pom xml dependencies:

<dependency>   <groupid>javax.servlet</groupid>   <artifactid>javax.servlet-api</artifactid>   <version>3.0.1</version>   <scope>provided</scope> </dependency> <dependency>   <groupid>jstl</groupid>   <artifactid>jstl</artifactid>   <version>1.2</version> </dependency> 

my web.xml declaration tag:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"      xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"      xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"      version="3.0"> 

and jsp part:

<%@ page contenttype="text/html;charset=utf-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  <html>  <head> <title>parsing results</title> <link type="text/css" rel="stylesheet" href="css/page.css"/> <link type="text/css" rel="stylesheet" href="css/table.css"/> </head>  <body> <h2 align="center">results of  parsing. parsing method = <c:out value="${command}"/></h2>....... 

edit: code, sets command value, simple:

request.setattribute("command", parser.getname()); 

then goes

request.getrequestdispatcher(redir).forward(request, response); 

tell me please, i'm doing wrong! thx!

yes, have doctype in web.xml <!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "java.sun.com/dtd/web-app_2_3.dtd"; >

remove <!doctype> web.xml , should well. valid servlet 3.0 (tomcat 7, jboss 6/7, glassfish 3, etc) compatible web.xml below in entirety, without <!doctype>:

<?xml version="1.0" encoding="utf-8"?> <web-app      xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"     version="3.0">      <!-- config here. -->  </web-app> 

for servlet 3.1 (tomcat 8, wildfly 8, glassfish 4, etc) below:

<?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. -->  </web-app> 

when using jstl 1.1 or newer, need assure web.xml declared in such way webapp runs in @ least servlet 2.4 modus, otherwise el expressions won't work in webapp.

when still having servlet 2.3 or older <!doctype> in web.xml, though have servlet 2.4 or newer xsd, still forced run in servlet 2.3 or older modus, causing el expressions fail.

the technical reason is, el part of jstl 1.0 , not available in servlet 2.3 / jsp 1.2 , older. in jstl 1.1, el removed jstl , integrated in jsp 2.0, goes along servlet 2.4. so, if web.xml declared run webapp in servlet 2.3 or older modus, jsp expect find el in jstl library, in turn fail if it's newer jstl version, lacking el.

see also:


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -