[RESOLVIDO]Erro uso de Expression Language c/ JSTL

4 respostas
lemosmoises

Estou usando a API core, e fazendo um simples exemplo de um página jsp. O problema está quando tento usar EL junto com o core. Ele redireciona a uma página de erro... A API core está na pasta lib do projeto e sozinha funciona. Como no código abaixo. Já no segundo código não funciona.

Se alguém puder me dizer qual é o problema agradeço.

<%@ 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>
	<!-- Importa JSTL Api core -->
	<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
	
	<c:forEach var="i" begin="0" end="4">
		<c:out value="teste"></c:out>
	</c:forEach>
	
</body>
</html>
Segundo código
<%@ 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>
	<!-- Importa JSTL Api core -->
	<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
	
	<c:forEach var="i" begin="0" end="4">
		<c:out value="${i}"></c:out>
	</c:forEach>
	
</body>
</html>
Meu web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>teste</display-name>
  <welcome-file-list>
    <welcome-file>bemvindo.jsp</welcome-file>
  </welcome-file-list>
  
  <error-page>
  	<error-code>404</error-code>
  	<location>/404.html</location>
  </error-page>
  
  <error-page>
  	<exception-type>java.lang.Exception</exception-type>
  	<location>/erro.html</location>
  </error-page>
  
</web-app>

4 Respostas

lemosmoises

Ninguém? :?

F

Troque a importação <%@ taglib prefix=“c” uri=“http://java.sun.com/jstl/core” %> por <%@ taglib uri=‘http://java.sun.com/jsp/jstl/core’ prefix=‘c’%>

Mas talvez fosse interessante tirar a configuração no web.xml para redirecionar quando der erro 404 pois fica muito dificil a visualização do problema, pelo menos enquanto estiver em desenvolvimento.

lemosmoises

Cara, funcionou direitinho, muito obrigado fabianosandi.

Mudei a linha conforme falou e já era…

Só uma dúvida, Pq esse tipo de erro?

lemosmoises

Estranho, modifiquei o web.xml conforme indicou também, e agora está funcionando dos dois jeitos…

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

De qualquer jeito Valeu as dicas!

Criado 1 de março de 2011
Ultima resposta 1 de mar. de 2011
Respostas 4
Participantes 2