Tutorials for JSLT
November 22, 2004 2:25 PM   Subscribe

I need be somewhat familiar with JSLT for a job interview/test next week. Anyone know of any good tutorials or have any magic tips? I'm coming from a PHP background and have never worked on a JSP site before.
posted by 4easypayments to Education (7 answers total)
 
This is where I started out learning about JSTL, and is a good starting point.

To understand that though, you'll need to have a grasp on taglibs and some JSP basics as well. I'm about as familiar with PHP as you sound like with JSP so I'm not much help with any analagous stuff.


Basically, JSTL is simply a set of custom tag libs that allow you to do stuff in JSP that previously required you to embed java code right in your JSP (something to avoid if possible).

There are 4 packages in JSTL.

core - the most often used, includes iterator and variable manipulation tags
fmt - formatting tags, allows you to print nice versions of dates/numbers/etc, as well as internationalization tags
xml - allows you to process/display XML tags right in your jsp code
sql - probably the least used (IMO) of all of the tags, they allow you to do database access right in your jsp, thereby violating all kinds of design rules that you should be following. Ok for prototyping, not a good idea for a "real" project.

In addition to these tags, you'll also need to get familiar with EL (expression language). It's a powerful way to allow you to refer to objects and their properties within a JSP page.

ex. the EL: "${employee.salary}" is the same thing as saying employee.getSalary() in java.

EL is built into the latest versions of JSP servers (2.3 and later I believe), and therefor don't have to be used exclusively in JSTL tags, but many places aren't using those yet.

Depending on the place that you're interviewing at, I'd concentrate the most on the core and formatting tags as well as being comfortable with EL.

I've also got the Struts Kick Start book by Sams and have found it useful, but it might be a bit outdated now.
posted by freshgroundpepper at 3:48 PM on November 22, 2004


Response by poster: Thanks, freshgroundpepper! That was exactly what I needed. That was a seriously great answer.
posted by 4easypayments at 3:56 PM on November 22, 2004


Hope it helps, good luck on your interview! :)
posted by freshgroundpepper at 4:00 PM on November 22, 2004


If you have something of a Q&A session about JSTL, features I've found useful about it are:

1. No null pointer errors. <%= foo %> will throw an exception all over your JSP page if "foo" doesn't exist, but the JSTL equivalent <c:out value="${foo}" /> is guaranteed to never throw a null pointer, even if ${foo} is undefined.

2. Using JSTL to import remote resources using <c:import /> is much simpler than any Java implementation, and you get caching for free.

3. Parsing or transforming XML is exceedingly simple with the built-in tags -- much nicer than writing a bunch of Java routines just to run XSLT over a document.

Good luck!
posted by nev at 5:31 PM on November 22, 2004


Response by poster: Thanks nev!

Oh, and I just noticed: perhaps I should start calling it JSTL instead of JSLT. That wouldn't go over well.
posted by 4easypayments at 10:36 PM on November 22, 2004


oops, I said I've got the struts kick start book by sams (which I do have), but the one that I meant to say was the JSTL kick start book (also by Sams). Decent intro and worth the money if that'll be one of your primary job responsibilities.

Nev makes some good points about things you can talk about with JSTL.

One other thing that would be nice to talk about are some of the more complex things that you can do with EL. In addition to variable expansion, you can also use it to do simple arithmetic ( "${employe.salary + employee.bonus}" as well as boolean statements ( "${employee.salary gt 100000}" ). Boolean statements are particularly useful in c:if blocks which allow you to conditionally enter a JSP fragement.
posted by freshgroundpepper at 12:24 AM on November 23, 2004


I'm a PHP guy who's just started a contract working on a JSTL site (responsible for the V in MVC). I've found it remarkably easy to pick up - it probably helps that I'm very comfortable with XML. The Struts User Guide (specifically the Developer tag guides on the left of that page) had pretty much all of the info I needed to get started in my first day.
posted by influx at 1:13 AM on November 23, 2004


« Older Did Mapquest remove alternate routes?   |   Any advice for learning how to play bass guitar? Newer »
This thread is closed to new comments.