Reputation: 2327
I'm trying to set the local in JSP.
I thought I'd be able to do something like:
<fmt:setLocale value="${param['local']}" scope="session"/>
Java's own page on the topic seem to say exactly so much.
However, when I go to execute this, I get:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /pages/ResourceBundlesJSTL.jsp(11,0) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1232)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:868)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1787)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:211)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:360)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:316)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.2 logs.
Apache Tomcat/7.0.2
I've also tried
<fmt:setLocale value="<%= param['local'] %>" scope="session"/>
and I get the same error.
Upvotes: 0
Views: 6672
Reputation: 1109302
There are several possible causes. It's not directly obvious from your question which one it is. I'll mention them all here anyway.
This can happen if your web.xml
root declaration does not comply at least Servlet 2.4 (which implies JSP 2.0 which is when EL is supported in runtime taglibs). Since that's already several years old and you're using a Servlet 3.0 compatible servletcontainer, I'd redeclare it as Servlet 3.0.
<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">
This can also happen if the fmt
taglib declaration does not comply at least JSTL 1.1 (which is designed for JSP 2.0). Ensure that it look like as per the TLDDOC:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
(the absence of /jsp
would indicate JSTL 1.0)
This can also happen if you actually have an outdated JSTL version in your Webapp/WEB-INF/lib
or Tomcat/lib
, like JSTL 1.0 or even the legacy Jakarta one. For Tomcat 6.x or newer, it's best to pick JSTL 1.2 here (and don't forget to remove the old standard.jar
as well!).
Upvotes: 5