• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I can't get JSTL to work with Eclipse

 
Ranch Hand
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
paul nisset
Ranch Hand
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 572
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic