p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   JSP Basics (http://p2p.wrox.com/forumdisplay.php?f=92)
-   -   JSTL (http://p2p.wrox.com/showthread.php?t=693)

mrkhairy June 18th, 2003 08:59 AM

JSTL
 
Hi,

I followed carefully instructions in Beginning JSP 2.0
in installing Tomcat and JSTL. All examples went well, but when I try
examples in chapter 2 - RequestHeader (request.jsp). These are the only thing appeared on the browser :

You sent the following request headers:

+------------+--------------+
| Header | Value |
+------------+--------------+
|${entry.key}|${entry.value}|
+------------+--------------+

For your info,
I using a standalone Win2K Advance Server, Apache
Tomcat4.1, J2sdk1.4.1_02 and JSTL 1.0.2.

Thanks.

todge June 18th, 2003 11:28 AM

Have you set up a complete directory structure?
e.g.
 ..\tomcat\webapps\AppName
 ..\tomcat\webapps\AppName\WEB-INF
 ..\tomcat\webapps\AppName\WEB-INF\classes
 ..\tomcat\webapps\AppName\WEB-INF\lib

Even if empty, I think JSP complains if they are not there...

(Also check the taglib directive, and web.xml files ...)

troutguy June 24th, 2003 08:30 AM

The same thing is happening for examples I'm using from the same book.

Server is not throwing errors but merely ignores the variables it's supposed to process.

It's done it for all exercises for me so far including something as simple as:

4 * 4 is ${4 * 4} Instead of showing 16 it just returns 4 * 4 is ${4 * 4} without evaluating.

Tried putting values inside <% %> symbol but that made no difference.??

I'm using BEA WebLogic Express, Win 2000 Pro.




Steve Garrison
Wilmington, DE

Charles Howard July 28th, 2003 08:21 AM

I've got the same problem. I'm using the Tomcat 5.0 alpha; my impression is that Tomcat 4 does not support the JSTL expression language in the way shown in this book; you have to use
<c:out value="${somevalue}" />
That's how it goes in Shawn Bayern's excellent book JSTL in action.



mrkhairy July 30th, 2003 04:00 AM

Yeah, i agreed with Charles. Right now i'm using JWSDP which include Tomcat 5.0. So far, all examples went well with it.

pdenhaan August 8th, 2003 04:57 PM

The price of working with a technology that isn't finalised yet, probably. What might also cause a problem is that a JSP container is supposed to switch to what one could term "JSP 1.2 compatibility mode" -- without expression language (EL) support -- when it finds a WEB-INF/web.xml file that conforms to the old Servlet 2.3 DTD rather than the 2.4 schema. It's undefined what happens if you don't have a web.xml file at all.

Many of my co-authors seem not to have realised this. Of course, it all worked fine in our prerelease software, making it easy to remain blissfully unaware of this. It will not work in production releases.

One thing to appreciate about the JSTL tags: if, in a JSP 1.2 container, you say

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<c:out value="${somevalue}"/>

you are passing the String "${somevalue}" into the JSP tag. This tag then calls an EL parser which figures out what you mean and evaluates the expression.

If, on the other hand, in a JSP 2.0 container you say

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:out value="${somevalue}"/>

the container evaluates the ${somevalue} expression, which might return a primitive or any Object, and passes the result into the tag. That's why you need the _rt versions of the tags in a JSP 2.0 container. From a tag's perspective, the two code fragments above work completely differently even if they are the same to you.

The advantages? The main advantage is that EL is no longer restricted to the JSTL tags, as you do not need EL support in the tags themselves -- in a JSP 2.0 container, EL works for any tag, and can also be used in the HTML text itself.

 - Peter



All times are GMT -4. The time now is 03:59 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.