aspose file tools*
The moose likes JSP and the fly likes Unable to get EL to work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to get EL to work" Watch "Unable to get EL to work" New topic
Author

Unable to get EL to work

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Hey folks,

I'm trying to create a simple web application using the IDE WSAD (WebSphere Studio Application Developmer - the commercial version of Eclipse) and I'm having difficulty getting EL to work.

Here's my current JSP file:



Obviously, it's a simple page and should pull the "user" attribute from the request twice. Unfortunately, it pulls it only once from the request (using the scriptlet), and the EL expression simply prints as if it were plain text - nothing is interpreted.

Here's the web.xml file I'm using (which was generated automatically by WSAD):



I had a suggestion from Kathy Sierra to change the webb-app tag to read like this:



Unfortunately, any time I try to change the web-app tag, I get a bunch of errors from WSAD that I can't seem to resolve.

Anyone run into this issue before? Anyone have any ideas as to what I can do to get this working?

Thanks,
Corey
[ October 25, 2004: Message edited by: Corey McGlone ]

SCJP Tipline, etc.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

I've only used Servlet 2.4 and JSP 2.0 with Tomcat 5 and Resin 3. Really dumb first question: are you sure that your instance of WSAD supports Servlet 2.4/JSP 2? The fact that it chokes on the 2.4 web.xml descriptor is suspicious.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Bear Bibeault:
I've only used Servlet 2.4 and JSP 2.0 with Tomcat 5 and Resin 3. Really dumb first question: are you sure that your instance of WSAD supports Servlet 2.4/JSP 2? The fact that it chokes on the 2.4 web.xml descriptor is suspicious.


I've wondered the same thing, Bear. Unfortunately, I've never used WSAD and neither has anyone in the office, so I'm not even sure how to find out. I've done some poking around, but I haven't found it yet. Meanwhile, I posted that exact question in the IDE forum. Hopefully, I'll figure that out soon.

If you notice the current DTD included in the web.xml file, you'll see that it's referring to servlet v2.3, not 2.4. That doesn't necessarily mean that my app server doesn't support 2.4, but, like you said, it's suspicious. That still doesn't tell me which JSP spec it supports, though.
[ October 25, 2004: Message edited by: Corey McGlone ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Ahem. I may have found my problem. I managed to find this buried in a help file:


The Web development environment in WebSphere Studio provides the tools necessary to develop Web applications as defined in the Sun Microsystems Java Servlet 2.3 Specification and the Sun Microsystems JSP 1.2 Specification. Web applications include static Web pages, JavaServer Pages (JSPs), Java servlets, deployment descriptors (web.xml files), and other Web resources.




Gah! So that seems to be my problem - it doesn't understand EL because EL wasn't added until the JSP 2.0 spec. That, of course, brings up another question of mine (since I've been out of the web app world for a couple years) - what else has been added to the JSP 2.0 spec that I won't be able to use? Anyone know of a page (perhaps on java.sun.com) that lists the new features in JSP 2.0 that I won't have available to me?

I also need to find out if we can/will upgrade, but that's not a question for these forums.

Thanks, folks.
Corey
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

The JSP 2.0 Spec will point out what's new over JSP 1.2.

You still can use the EL to a limited degree under JSP 1.2, but it is limited to attributes within the JSTL 1.0 implementation. To use the EL stand-alone within the pages as your example shows requires JSP 2.0.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Thanks for the help, Bear. I think I just needed someone to confirm what I had suspected. I have a feeling you're going to be seeing more of me in this forum in the near future.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Out of curiosity, what's the best way to get dynamic information into a JSP using the 1.2 spec? Obviously, I can't use EL, so, in that case, am I back to using scriptlets and expressions in my JSPs? Or is there a better way to get information from the request into my JSP files?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

You can still write scriptless pages in JSP 1.2; it's just not as easy as with JSP 2.0.

Get a copy of the JSTL 1.0 and use the <cut> tag where you would use "stand-alone" EL expressions.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Or, trade in WSAD for a more modern container. (I assume you have no choice in the matter?)
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Bear,

Unfortunately, I don't really get much say in the matter of which IDE and container we'll be using. For the time being, it looks like I'm stuck in the J2EE 1.3 world.

Anyway, I was trying to get the JSTL tags to work in a sample web app and I'm having problems. First of all, let me point out that I'm using Tomcat 5 (which supports JSP 2) to run my little test and I'm still having problems so the issue isn't support. It has to be something with my app. Anyway, I made a simple .jsp file that looks like this:



My goal is simply to replace the scriptlet expression with the cut tag, as you recommended. Unfortunately, if I try to execute this page, I get an error that looks like this:



I moved the jstl.jar file into my WEB-INF/lib directory, but is there something more I need to do? I actually copied that page directive from the file webapps/jsp-examples/tagplugin/choose.jsp (which is one of the sample JSPs that comes with Tomcat). I've executed choose.jsp and it works just fine, but I get the error when I try to execute my own jsp in my own web app.

Is there something else I need to do in order to get this to work? I thought copying the .jar file was all I needed, but that doesn't seem to be the case.

Thanks,
Corey
[ October 25, 2004: Message edited by: Corey McGlone ]
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Ok, I think I've got it resolved. The problem was that the TLD file which identified the jstl tags wasn't in the jstl.jar file. It's actually in a second .jar file (located in the same place), called standard.jar. I moved that file from the existing sample web app into my own web app and it started working properly.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Also be aware of which JSTL version you are using. The URI http://java.sun.com/jsp/jstl/core is a JSTL 1.1 URI. You probably want to be using JSTL 1.0 with JSP 1.2.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Bear Bibeault:
Also be aware of which JSTL version you are using. The URI http://java.sun.com/jsp/jstl/core is a JSTL 1.1 URI. You probably want to be using JSTL 1.0 with JSP 1.2.


Yes, I am. I found that the URI for JSTL 1.0 is "http://java.sun.com/jstl/core", which is slightly different from the URI for JSTL 1.1.
Ryan Tyer
Greenhorn

Joined: Sep 01, 2004
Posts: 6
Just as a heads up, Websphere Server 6 (J2EE 1.4 compliant) will be available to my employer (big ol websphere shop) in November, as will WSAD 6 (based on eclipse 3 instead of 2.1x). I don't think that this is any kind of early access program or anything, so if your client/employer has a current IBM contract, you might look into it.
 
Consider Paul's rocket mass heater.
 
subject: Unable to get EL to work