问题
Error on run time:
index.jsp(12,8) PWC6038: "${sqlStatement == null}" contains invalid expression(s):
javax.el.ELException: Unable to find ExpressionFactory of type:
org.apache.el.ExpressionFactoryImpl
org.apache.jasper.JasperException: : javax.el.ELException: Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl
Questions:
- How would I go about debugging this?
- Unable to find ExpressionFactory of type: org.apache.el.ExpressionFactoryImpl <-- what does this mean?
This is what I have
- NetBeans IDE 7.3
- Tomcat 7.0
- MySql connection
This is a simple sql gateway from Murach's book
index.jsp
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:if test="${sqlStatement == null}">
<c:set var="sqlStatment" value="select * from User" />
</c:if>
<h1>The SQL Gateway</h1>
<p>Enter an SQL statement and click the execute button. Then, information about the<br/>
statement will appear at the bottom of this page.
</p>
<p><b>SQL Statement:</b></p>
<form action="SqlGateway" method="POST">
<textarea name="sqlStatement" cols="60" rows="8">${sqlStatement}</textarea>
<br/><br/>
<input type="submit" value="Execute">
</form>
<p><b>SQL result:</b></p>
<p>${sqlResult}</p>
web.xml
<servlet>
<servlet-name>SqlGatewayServlet</servlet-name>
<servlet-class>sql.SqlGatewayServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SqlGatewayServlet</servlet-name>
<url-pattern>/SqlGateway</url-pattern>
</servlet-mapping>
I don't think there is anything wrong with the servlet, but if you need me to post it please let me know.
回答1:
Could it be something wrong with my el-api.jar file
You should not have any servletcontainer-specific JAR file in your webapp's /WEB-INF/lib
. Servletcontainer-specific JAR files are supposed to be already provided by the servlet-container itself.
Look in Tomcat's /lib
folder, it already ships internal libraries, JSP, Servlet and EL libraries. You do not need to supply any of them via your webapp. If you still do it, the runtime classpath may end up in a disaster because there are duplicate different versioned libraries. In your specific case, you likely supplied a randomly downloaded EL API via your webapp which didn't match the EL impl found in the runtime classpath and thus the right impl can't be found via the abstract factory pattern.
So, if you get rid of servletcontainer-specific JARs in /WEB-INF/lib
, then all should be well. The /WEB-INF/lib
should contain only libraries which are specific to the webapp itself and are not already provided by the servletcontainer.
See also:
- How do I import the javax.servlet API in my Eclipse project?
来源:https://stackoverflow.com/questions/17979369/contains-invalid-expressions-javax-el-elexception