- This topic has 8 replies, 4 voices, and was last updated 19 years, 10 months ago by
Mork.
-
AuthorPosts
-
Hi,
I’m trying to get JSTL working under MyEclipse and Tomcat 5.5.
I have some code like below, but it isn’t “doing anything”.
I tried doing an <%@ taglib ….> to point to the java.sun.com “core” jstl classes but that didn’t work either.
I thought there was some way to add JSTL to a MyEclipse project but I can’t find it.
Can anyone lend me a hand in getting started?
Do I also need to install jar files into Tomcat?
Thanks!!!
— Mike
———————————————-
<%@ page language=”java” import=”java.util.*”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + “://” + request.getServerName()
+ “:” + request.getServerPort() + path + “/”;
%><!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<base href=”<%=basePath%>”><title>My JSP ‘MyJsp.jsp’ starting page</title>
<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”><!–
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
–>
</head><body>
This is my JSP page.
<br><c:if test=’$(not empty param.amount)’>
<% String s = “JSTL is the future!”;
pageContext.setAttribute(“name”, s);
%><c:out
value=’$(param.amount)’/>
<c:else>
Else code running…
<c:out value=’$(param.amount)’/>
<c:out value = ‘$(name)’ />
Else code ran!</c:if>
</body>
</html>————————————
In Tomcat 5.5, it just prints:
This is my JSP page.
Else code running… Else code ran!————————————-
Thanks for any help or suggestions.
— Jim
Riyad KallaMember1) Right click on project root, MyEclipse > Add JSTL Jars
2) Make sure the JARs were added to your build path (standard.jar and jstl.jar)
3) File > New > JSP > JSP Page with JSTL 1.1
4) Have fun editing OR just copy the <%@taglib %> entry into your existing page (this is required).Do you mean this:
<%@ taglib uri=’http://java.sun.com/jstl/core’ prefix=’c’%>(I have this in the body tag)
I’m getting a strange error: “org.apache.jasper.JasperException: /MyJsp.jsp(39,0) According to TLD or attribute directive in tag file, attribute test does not accept any expressions”
on this line:
<c:if test =’${!empty param.amount}’>
The two jars did get deployed, lots of .tld fifes too.
I call the JSP from the browser like this:
http://localhost:8080/JSTLTest/MyJsp.jsp?amount=100Any idea what might not be set up right?
(I created a new JSTL 1.1 project for this)
Look forward to your reply.
Thx.
–M
Riyad KallaMember<c:if test =’${!empty param.amount}’>
Use double quotes, not single.
I think you might be accidentally using the JSTL 1.0 libs, then you have to use the core-rt tags to use expressions. Create a new text project, make sure to select JSTL 1.1, then you can just use the straight core tags, they include support for expressions.
I’m using code directly from “Core JSTL” published by SunPress. It uses single quotes not double quotes (for a test, I tried double quotes anyway, but I got the same error…).
I clicked on the 1.1 libraries when I created the project.
My input to the browser is this:
http://localhost/JSTLTest/MyJsp.jsp?amount=100
But the error message is this:
org.apache.jasper.JasperException: /MyJsp.jsp(38,0) According to TLD or attribute directive in tag file, attribute test does not accept any expressions
————————————————————
I SPECIFICALLY CLICKED TO USE THE JSTL 1.1 LIBRARIES, BUT THE LIST BELOW LOOKS LIKE MYECLIPSE USED ONLY THE 1.0 LIBRARIES…..
IS THIS A MYECLIPSE BUG OR AM I MISINTERPRETING THE LIST BELOW?
————————————————————
Here are the .tld files in the WEB-INF Folder:
Directory of C:\Program Files\Apache\Tomcat 5.5\webapps\JSTLTest\WEB-INF
04/12/2005 07:08 AM 10,763 c-1_0-rt.tld
04/12/2005 07:08 AM 11,310 c-1_0.tld
04/12/2005 07:08 AM 15,999 c.tld
04/12/2005 07:08 AM 11,409 fmt-1_0-rt.tld
04/12/2005 07:08 AM 12,580 fmt-1_0.tld
04/12/2005 07:08 AM 19,595 fmt.tld
04/12/2005 07:08 AM 7,298 fn.tld
04/12/2005 07:08 AM 1,169 permittedTaglibs.tld
04/12/2005 07:08 AM 1,722 scriptfree.tld
04/12/2005 07:08 AM 5,372 sql-1_0-rt.tld
04/12/2005 07:08 AM 6,127 sql-1_0.tld
04/12/2005 07:08 AM 8,446 sql.tld
04/12/2005 07:08 AM 7,200 x-1_0-rt.tld
04/12/2005 07:08 AM 7,673 x-1_0.tld
04/12/2005 07:08 AM 12,290 x.tld
15 File(s) 138,953 bytes
0 Dir(s) 48,051,023,872 bytes free===================
I look forwardto your reply
Thanks!!!
— M
Scott AndersonParticipantMike,
That list is the JSTL 1.1 library list. The libraries with the -1_0 in the name are for backward compatibility so your 1.0 apps work with 1.1 also.
But, this is the 1.1. list. Perhaps you’re simply referring to the wrong TLD in your JSP, and picking up one of the 1.0 versions instead?No, the problem turned out to be that Tomcat 5.5 was parsing the code before JSTL could get a hold of it.
All I needed, as it turned out, was a:
<%@ page isELIgnored=”true” %>
at the top of the page.
— M
timmorrowMemberI realize this thread is old, but it showed up high in a Google search for the JasperException.
The real problem is the taglib uri. Instead of adding the
<%@ page isELIgnored=”true” %>
directive (which prevents the servlet container from parsing the EL, I think)all you need to do is change
<%@ taglib uri=’http://java.sun.com/jstl/core’ prefix=’c’%>
to
<%@ taglib uri=’http://java.sun.com/jsp/jstl/core’ prefix=’c’%>
This will correctly use the JSTL 1.1 taglibs and cause the servlet container to parse the EL successfully.This assumes your web.xml is a servlet 2.4-style web.xml (specifying a schema instead of a DTD).
Tim
Thanks!
-
AuthorPosts