GeeCON Prague 2014*
The moose likes IDEs, Version Control and other tools and the fly likes I can't get JSTL to work with Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "I can Watch "I can New topic
Author

I can't get JSTL to work with Eclipse

paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 171

Hi ,
From spending the last two hours Googling why this doesn't work,this should be a lot simpler than it is turning out to be.
I am rapidly coming to the conclusion that JSTL is way more trouble than it is worth.

I am using Eclipse .
With a Tomcat version 6 ,the following code does not work at all .
With Tomcat version 7 ,instead of outputting parameter values it is just outputting the literal string - "${err}" .
Pretty useless.
The page is definitely receiving the parameter "error" .

I have copied jstl-1.2.jar into a directory called "lib" under WEB-INF .

If anything sticks out please let me know.
Code is at the bottom.

thanks,
Paul


Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

I believe you need to be pointing to a TLD file, so something like this should go in your web.xml:




And then, of course, the TLD actually has to be where you say it is.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

What's really more trouble than it is worth is doing your own login process. I know people are really tired of me saying this, but user-designed login/security systems just don't work.

As far as JSTL is concerned, first make sure that there isn't already a JSTL jar in the Tomcat server lib directory. JSTL is part of the J2EE standard, so in theory, JSTL is pre-supplied by the server. Tomcat, however, is not a complete J2EE implementation, however, so check and see.

The taglib information should not be necessary. These days, TLDs are almost always bundled into meta-information in the jar that implements the taglib (jstl.jar). So that strategy will probably not help.

You might also try running Tomcat stand-alone without Eclipse. If, as is common, you are using the WTP eclipse plugin that comes pre-installed with the J2EE spin of Eclipse, that particular feature is an abomination that does not faithfully reproduce the Tomcat environment as it would be in a stand-alone server. And, while in this particular case I can't think of anything that it would be doing to sabotage you, at least there would be one less complication.


Customer surveys are for companies who didn't pay proper attention to begin with.
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 171
Thanks for your comments .
What is troubling me is that it seems to be seeing the library and taglib as it can do a <c:out value="sometext" />

I'l look into alternatives to the user supplied log in process.
Any pointers to alternatives would be welcome.
-Paul
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

You can find basic information on the J2EE standard security framework in just about any good introductory servlet/JSP book. The author then typically ruins it all by doing an example with a user-defined login process

The bulk of the security comes from elements you configure in web.xml, including transport security, the login/loginfail pages, and role definitions and their URL mappings. There are also API functions that integrate into the system for assisting in user identification and authorization checking.

Because the front line of defense in j2EE security is the server itself, not the application, you also configure a security provider, called a Realm in the webapp server. Realms are typically plug-replaceable, providing a choice of security providers such as databases, LDAP servers and single-signon security services. Some, such as Tomcat, also have simpler realms that keep their info in files - the Tomcat conf/tomcat-users.xml file is used by the Tomcat MemoryRealm, for example. This one is good for testing because you don't have to have a formal security service online.

On your other (original) problem, a second look makes me think that you have confused JSTL with EL. When you specify an expression such as "${err}", that's an EL (Expression Language) expression. Normally, the JSP processor should expand that automatically. In fact, "<c: out value="${err}"/> is redundant since ${err} should do the same thing here.

EL is built into Tomcat 6 and higher releases. It had to be manually included in the WAR for Tomcat 5.5.

My suspicion is that actually your problem is that you didn't declare err as an object in a useBean element, but I don't do much straight JSP these days, so I could be mistaken on that one.
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 171
Thanks for pointing that out .
I've not been super clear on the difference between EL and JSTL and tended to lump them in together .

Up until now I've tended to over use scriptlets and want to move away from that.
I like them because they are easy to drop in but it makes the code messy.

You're right about java books,they do tend to mention security frameworks but the examples will be simple login pages that don't use the framework.

cheers
-Paul
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Tim Holloway wrote:My suspicion is that actually your problem is that you didn't declare err as an object in a useBean element, but I don't do much straight JSP these days, so I could be mistaken on that one.


No, it's the <c:set> element which declares the "err" variable. No useBean needed here. It's true that the <c:out> part of the posted code is redundant, but it isn't wrong and the JSTL/EL code looks perfectly normal to me.

There could be various outcomes from the posted code, but "${err}" isn't one of them in JSTL. So there's something wrong, but it isn't in the posted code. So my guess is it's a configuration error of some kind. Not much fun to track down when you have both Tomcat and Eclipse in the picture. Did somebody suggest running Tomcat standalone? Yes, I see Tim did. I second that recommendation.
paul nisset
Ranch Hand

Joined: May 13, 2009
Posts: 171

I'll check to see what libraries are linked into each version of Tomcat I have.
Running it outside of Eclipse makes sense.

Thanks Tim and Paul for your comments.
They cleared up some things with EL and JSTL.

-Paul
 
wood burning stoves
 
subject: I can't get JSTL to work with Eclipse