Erro ao reconhecer JSTL

3 respostas
rafael.espiritosanto

Pessoal, tô usando o plugin WTP do Eclipse junto com plugin Exadel.
Tô fazendo uma jsp que usa a tag forEach. Só que não tá reconhecendo a
tag core do jstl.

Eis como tá o meu web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 <servlet>
  <servlet-name>login</servlet-name>
  <servlet-class>util.LoginServlet</servlet-class>
 </servlet>
 <servlet>
  <servlet-name>listarRecado</servlet-name>
  <servlet-class>recado.ListarRecadoServlet</servlet-class>
 </servlet>
 <servlet>
  <servlet-name>inserirRecado</servlet-name>
  <servlet-class>recado.InserirRecadoServlet</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>login</servlet-name>
  <url-pattern>/login</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>listarRecado</servlet-name>
  <url-pattern>/listarRecado</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>inserirRecado</servlet-name>
  <url-pattern>/inserirRecado</url-pattern>
 </servlet-mapping>
 <welcome-file-list>
  <welcome-file>/login</welcome-file>
 </welcome-file-list>
 <login-config>
  <auth-method>BASIC</auth-method>
 </login-config>
</web-app>

E assim tá minha jsp

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

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

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<table>
		<tr>
			<td>De:</td>
			<td>Para:</td>
			<td>Data:</td>
			<td>Hora:</td>
			<td>Mensagem:</td>
		</tr>
		<c:forEach var="recado" items="${recados}">
		<tr>
			<td>${recado.remetente}</td>
			<td>${recado.destinatario}</td>
			<td>${recado.data}</td>
			<td>${recado.hora}</td>
			<td>${recado.mensagem}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

Eu já ajustei o web.xml com Servlet api 2.4. Daí não sei porque não tá reconhecendo a tag ou jar do JSTL

Valeu pela ajuda!!!

3 Respostas

rafael.espiritosanto

Só mais uma coisa: Se eu usar a teg que o exadel dá de opção. A jsp funciona mas nenhum conteúdo é mostrado.

A jsp com ajuda do Exadel fica assim

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<c:JSTL Core taglib/>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here</title>
</head>
<body>
<table>
		<tr>
			<td>De:</td>
			<td>Para:</td>
			<td>Data:</td>
			<td>Hora:</td>
			<td>Mensagem:</td>
		</tr>
		<c:forEach var="recado" items="${recados}">
		<tr>
			<td>${recado.remetente}</td>
			<td>${recado.destinatario}</td>
			<td>${recado.data}</td>
			<td>${recado.hora}</td>
			<td>${recado.mensagem}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

Valeu!!!

K

experimenta declarar a taglib no seu web-xml

pra vc usar ela na jsp, vc precisa apontar o caminho dela

&lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
&lt;taglib&gt;
    &lt;taglib-uri&gt;http://java.sun.com/jstl/core&lt;/taglib-uri&gt;
    &lt;taglib-location&gt;/WEB-INF/tld/c.tld&lt;/taglib-location&gt;
&lt;/taglib&gt;

ahhh nao esquece de verificar se vc adicionou os jars no lugar certo

A

deve ser a biblioteca de tags… verifique se elas estao no projeto ou se a uri esta correta

Criado 8 de fevereiro de 2007
Ultima resposta 8 de fev. de 2007
Respostas 3
Participantes 3