JSP and Tag Libraries for Web Development
The Scoop Web developers and designers have long wrestled with strategies for combining their efforts. Web developers don't mind looking at code but dislike dealing with the look of a page, while Web designers are the opposite. Dynamic Web page technologies, such as Microsoft's ASP, Perl's many template systems and Web frameworks (Text::Template, HTML::Template, HTML::Mason, CGI::Application, etc.), and PHP, were designed to give both developers and designers a chance to do their work without stepping on each other's toes.
Sun's answer was to release the Servlet API and later extend that to make JavaServer Pages. Initially, there was no clear role separation for servlets and JSPs, since a servlet could generate and display HTML just as easily as a JSP could perform business logic. The Model 2 architecture, based on Smalltalk's Model-View-Controller (MVC) design pattern, showed that servlets and JSPs complemented each other. Tag libraries extended the functionality of JSPs in a way that made it easier for developers and designers to collaborate.
JSP and Tag Libraries for Web Development is mostly targeted at Web developers who want advice on designing JSP applications and incorporating tag libraries. The book covers custom tag libraries, the Jakarta Struts framework, and various commercial and noncommercial tag libraries, such as Jakarta Taglibs.
What's to Like? The author starts with an introduction to servlets and JSPs, including a decent explanation of MVC. If you are comfortable with servlets and JSPs, this discussion is really more of a review than anything else.The next two chapters introduce tag libraries and the author's example application (a simple article and author tracking system). The author illustrates the lifecycle of a tag, which helps if you haven't really used or written custom tags before. Da Silva also gives a very detailed discussion of tag library descriptors (TLDs). Some details might have been better left as an appendix, but it is nice to see such a comprehensive explanation of what you can put in a TLD.
Da Silva then spends about 100 pages on writing simple tags, iteration tags, body tags, and making all of these types of tags cooperate. The discussion is again very detailed, but seems unfocused in many parts. Very little of the code in these chapters ties in with his example application.
Next, the author spends three chapters on the Jakarta Struts framework. He explains how Struts naturally fits into the MVC design pattern and gives various examples of how to structure your Struts application. He also includes an entire chapter on finishing his example application, going over Struts ActionForms, Struts Actions (including a method to prevent double submission that I had not seen before), and Struts' method of internationalization on JSPs.
Finally, the author runs through the Jakarta Taglibs project and some commercial tag libraries. Brief examples are provided, but this chapter really needed more attention than da Silva gave it.
What's to Consider Overall, JSP and Tag Libraries for Web Development feels unfocused. The author's central points are explained well in many places, but lost in many others. With some reorganization, I think the book could make a much stronger case for appropriate uses of tag libraries, both application-specific and general (e.g. Struts and Taglibs).Sections where general tag libraries are discussed read very much like the documentation available on project Web sites, such as the struts-html tag library documentation. These really should have been left as an appendix, with better explanations and usage examples provided in their place.
I was also very disappointed in the author's use of Struts Action classes. He combined various actions (add, edit, delete, etc.) to perform on a specific object and tested for a URL parameter to decide what to do. In my opinion, each action should be encapsulated in one Action class (AddObjectAction, EditObjectAction, and DeleteObjectAction). The author's design leads to URL hackery which Struts tries to avoid.
Recently, Struts released a stable version of the 1.1 series, which this book does not cover (it was published in early 2002). Readers should be familiar with the Struts documentation for this release before picking up this book.
The book's Web site is under construction, and I've been able to find little information on the publisher's site.
The Summary A okay book with room for improvement. While the author shows his technical knowledge, the book loses its direction in places. Most developers can probably get by with the documentation available on the Web. Table of Contents- Understanding the Tag Library Extension API
- Introduction to Servlets and JavaServer Pages
- Introduction to Tag Libraries
- Writing Custom Tags
- Cooperating Tags and Validation
- Design Considerations
- The Struts Framework
- The Jakarta Struts Project
- Struts Tag Libraries
- Anatomy of a Struts Application
- The Jakarta Taglibs and Other Resources
- The Jakarta Taglibs Project
- Commercial Tag Libraries
- Other Resources
- Appendices
- Tomcat
- Allaire JRun
- Orion
- MySQL
- Mapping Servlet-JSP Objects
- The Apache Software License, Version 1.1
You can purchase the JSP and Tag Libraries for Web Development from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Not to mention AxKit in those lists of templating systems?
A great list of other introductory JSP books can be found here...
You said that most of this is avaiable on web. Would there be any real reason to buy this book then? Does it offer anything special or unique? I might have missed where you said this in your review. If i did. Sorry.
Everyday You see me is the worst day of my life -Office Space
if it doesn't include JSTL and JSF technologies.
DON'T BUY IT!
This book looks seriously out of date.
This isn't true. You can output HTML from a Servlet, that much is sure, but it is much smarter (and less work) to use a JSP instead. Think of all those out.println("") statements if you were to use Servlets... ugly!
Velocity makes a nice alternative to JSP for the View layer. You can plug it into Struts and use it in place of JSP, or you can embed Velocity into JSP with the Velocity JSP tag.
There's a pretty good user's guide on the Velocity web site if you want to take a look through it.
Tips and Tricks for Mozilla
Don't trust him! He goes on Usenet all the time and he dynamically amalgamates posts about Java servlets and HTTP, passing the comments out for his own.
Sad that this hack actually got a book deal(!). The truth is, I've met Wellington...he's actually a nice man. He lives in Mombasa, and he's happiest when he's on safari. He really fills out field khakis and a pith helmet, let me tell you...
But if you ever see him on USENET, beware! His foppish charm doth not extend to the virtual realm.
(-1, Raw and Uncut is the only way to read)
Might make a better team than JSP and Java. Check this out. Zend and Sun are working together on a java specification request that will interwork the easy development of PHP as a web front end to the powerful business logic systems that java provides. Sure you can do SOAP server with PHP, but that's not as good as having a SOAP server with Java (or any other sort of server) and slapping a PHP web interface on top of it. I can't wait until it's ready.
--------
Free your mind.
sigh
This one is a great addition to the book shelf, I know how to do certain things with JSP by using the docs, but this book clarifies nicely why you are actually doing it and provides better language specific ways of doing things that might now occur to you. Also, it introduces nice JSP concepts in a clear and easy way which scripters might not have come across before.
To start Java Bashing, or SUN bashing! Or commenting on how there are other languages that provide the same result with less effort!
Something about memory usage, overhead, xml based config files...
Maybe just promote PHP to the extent that it sounds like some nigerian spam!
Now that I got that out of that way, I hope I save some of you a lot of time! Now I'm exhausted, time for a nap!
It looks ASP.Net (Not ASP) is much more advance than JSP, as well as the development tool (VisualStudio.Net vs Netbeans).
http://mav.sourceforge.net/
.NET
is a great MVC - *without* the hideousity of Struts et al. Simple, clean, easy - and you can even use velocity templates. It's even been ported to PHP *and*
h.
Siggy played guitar, jammin' good with Weird and Gilly
Patriotism is a virtue of the vicious
Oh yeah. Like THAT was an intelligent post. Like many others before you... YOU FAIL IT!!!!
:)
Guess what? I trolled myself.
Un-news
www.cgisecurity.com
Maybe some other people can comment on this, but I find tags a needless amount of work in servlet-oriented systems.
If you have a tag that you're using to operate on some data before presenting it, why not encapsulate that data in an object (which it probably already is) and make it a method?
I have a better solution, though - how about dumbass web "designers" who don't know jack about programming go back to their worthless design schools and munch on my choad?
Anyone performing this kind of development forgot a key aspect of designing their servlet/JSP. MVC gets bandied about again and again as the thing to do, but most of the servlets I've seen have nothing to do with MVC.
If you want real MVC, your servlet which receives the request would be considered the Control (C) as such, it shouldn't have any System.out.println(...) requests in it at all. That would be part of the View (V).
A much better solution is to write 3 modules for each web page you are presenting. One for the receiving servlet (C) which then manipulates the Model (M) appropriately, and redirects the requests to the appropriate JSP (V) with additional information in the form of JAVA Beans.
Now you have real MVC! Your model doesn't have to control your interface, and your view cannot request data your Control servlet didn't pass along the redirect. It's many more modules to write, but each one is smaller and much easier to maintain.
I was also very disappointed in the author's use of Struts Action classes. He combined various actions (add, edit, delete, etc.) to perform on a specific object and tested for a URL parameter to decide what to do. In my opinion, each action should be encapsulated in one Action class (AddObjectAction, EditObjectAction, and DeleteObjectAction). The author's design leads to URL hackery which Struts tries to avoid.
Well, if you've ever worked on a moderate to large scale system, you realize you're going to have a gazillion java classes, many of which may be trivial. Not fun to manage!
The real question is... What can it do for me in the Portal environment.
Struts and Taglibs don't lend themselves well to Portal environments especially with the tendency towards CSS's to position elements. Portals don't like this.
You can skip any Java JSP / Servlet book that doesn't mention JSTL. Sun finally put out a standard set of tags that do most of the stuff that people used custom tags for in the first place.
Unless they somehow manage to cover the new Servlet 2.4 and JSP 2.0 APIs. True, only the Tomcat 5.0 beta support them yet, but still...
Amazon has it cheaper via the marketplace sellers.
Although I won't comment on the usefullness of this book, I imagine that you can come up with at least 10 reasons books haven't disappeared with the invention of the web.
Let's face it, there's a lot of books which aren't much better than a collection of dispartate web pages. But how hard is it to recogonize that books and the web both provide information but to different markets due to the ways in which they can be used?
One less blindly pro-Java moderator point.
How do you like the fact that Java has become a commodity?
Hope you like low paying entry-level work.
This book sounds pretty lame.
...the caveat is that this approach requires J2EE 1.3 (Tomcat 4.0+, WebSphere 5.0+, Weblogic since forever-ago).
First, even the Struts developers themselves consider all but the struts:html tags to be obsoleted by the JSTL (lots of struts newsgroup posts to support this...no time to provide a link). JSTL provides not only a fairly rich set of "nuts and bolts" tags, but more importantly a set of base classes that can be easily extended for custom tags (such as the choose/when/otherwise construct and iterator tags). For Struts, the JSTL expression language has been encorporated into the struts-el tags, included in the latest 1.1 release.
JSTL also obsoletes most of the Jakarta Taglib project's libraries, which frankly were very ugly from the start (separate tags for interacting with session/request/page objects? come on...check out the Expression Language that applies elegance to this problem, and is used in JavaServer Faces, JSTL, Struts-el, and everything useful from here on out).
As for templating engines, the biggest driver towards them has been the lame scriptlet-laden way JSP has historically been used (see The Problem with JSP). JSTL, Struts-el and before long JS Faces nail this problem, and IDE integration in the next year will make clear the reason why Template engines like Velocity aren't compelling (my opinion...not trying to offend).
.. is the fact that people try to make it yet another language. There are tags for (gasp) database and LDAP access, for email retrieval,etc.
What is the point of fighting MVC wars on subject of separation of the View and then load this View with logic again?
The whole idea of a JSP is to grab an Object from the request object and output its contents. The only code allowed in JSPs should be the %= obj.method() little things and simple loops to loop over the collections.
The tried-and-true architecture (what they call level 2) is to submit all the pages to the same URL (controller JSP or servlet), have it figure out what to do next, do it, load the request object with the data to be displayed and use RequestDispatcher to forward the request to JSP for display. Struts, etc does that but you do not have to use Struts, simple home-grown thing will do too.
Has anyone done a comparison of Java based web app frameworks? The list keeps growing and it is getting harder to choose. Stuts? Cocoon? Maverick? Help?
shooz
1. the guy describes this thing 2. bunch of others reply how stupid this idea is 3. the guy moderated Insightful
I've never used JSP and I'm wondering: could someone explain (or point to an explanation of) what a tag means in this JSP/Tag Libraries context? I only understand (from the context) that it's probably not "tag" as in "HTML tag", but that's about it.
Thanks in advance.
JP
I know that the CFML platform is often associated with simple, design-friendly web apps (e.g. intranets) but now that it is written atop Java (or J2EE) - it seems pretty attractive. One can't deny the elegance & ease-of-use of the CF markup language.
$86K for basic Java development suits me fine, thanks.
Try "Bitter Java" by Manning. I'm not saying that it has anything much better than a call to return to MVC, but it's written well, and it's code seems to be sanity-checked.
I checked out the "Problem with JSP" site, and many of the issues it raises are present in "Bitter Java". I don't agree that the JAVA bean tags are fundamentally worse (or better) than the alternative syntax templating provides, but the last example (manipulating the title) is a cop-out.
If the title is supposed to change in the header and footer, then the controller (which manipulates both the model AND the view) should pass the info along in a Java Bean. That would allow the header and footer to grab the title without the fear of "missing a semicolon" using the normal JSP bean extensions.
Some of their work is interesting, and I like the bit about loops, but a lot of it implys that they are complaining about badly coded JSP pages. I mean, a 30K JSP page? Only if you don't have any MVC, and inline the JSP at every opportunity.
Don't waste your time on Tag libs. The whole point of templating and abstraction is to remove the logic from the presentation. Tag libs is going the other way.
How small a thought it takes to fill a whole life
a book for JSP developers wanting to improve their 'skillset.'
Why coding in Java is a bad idea:
Makes you use terms like "skillset"
For modern approaches, you'll have to look outside of the java box. From the language/devel environment that brings us MVC, there's Seaside. Similar continuation-based approach is used more in the Lisp/Scheme community. On java platform, Coccon Control Flow also uses continuation.
I don't believe there's any book on those yet.
JSP is probably not the way to go in the first place. This informative article, JSP: A Total Waste of Time? sums up some of the core problems pretty nicely.
<a href="http://www.joblessjimmy.com">Work is dumb and so is Jobless Jimmy.</a>
Again I stare at a lame subject with surprise: what is such a subject doing in the front page of (gasp) almighty Slashdot?
.net as well, as asp.net has some very good set of tools. I would qualify asp.net as a combination of jsp/servlets + standard tag libs + templating. It has some caveats as using page controller pattern and too much ado.net placed directed in a page. But better than pure jsp/servlets. PHP is good for Personal Home Pages, period. Those big sites using it are having a pretty bad maintenance time (or will have soon). Zope is not general enough, but good enough for simple content managing. Maybe OpenCMS will catch up one day. Ruby? Doesn't counts for serious enterprise level applications. Bashing EJBs is not productive either, there are several situation where EJBs fit nicely, and dozen other that don't.
C'mon. This book is so old my grandma used to read it in elementary school.
Slashdot homepage is for really geeky subjects like new mathematical milestones, brand new technology reviews, (bashing microsoft & cia), etc.
And this subject was already so discussed: Pure J2EE Web support is pretty lame in the current version. JSP/Servlets are almost like having to build a rich application without AWT or Swing (using Graphics to draw lines and squares by hand).
Every single developer knows (or at least, has the obligation to know by now) that you just have to combine J2EE with some other framework. The basic toolset being Struts (workflow) + Validator + Tiles/JSTL (view templating) + Hibernate (persistence).
Every single developer knows (or should know) that one must never ever place database logic in a JSP page even through tag libs. One should always use some kind of persistence layer, any one (Hibernate, JDO, Entity Beans, whatever).
Every single developer knows that the best pattern is to avoid page controllers and use the front controller approach.
Every single developer knows that a serious web site must use templating, any one, be it cocoon, tiles, velocity, whatever.
This is so basic I don't even know why I'm wasting my time writing obvious facts. Anyway.
Ok, so someone doesn't know (so why are you calling yourself a "developer"?). Well, the web is full of resources so there's no excuse to not know something. And instead of bashing every single microsoft move, one would be smarter to know
Just be a good architect, analyse the situation, and choose the right set of tools.
Hasta la vista.
JSP = theoretical experiment gone awry.
... What? Pascal?
Let's bury it and move on to more commercial available techniques?
A good learning tool, but
I have yet to work on a web project that had folks that were only GUI designers.
All of our web pages were developed by developer/programmers.
By mixing scriptlets with HTML in your JSP files, everything that paints a web page is in one place.
If you have database issues, you don't have to go digging through bean code and custom tag library code to figure out why something didn't work.
We managed to meet business requirements with short duration projects.
In the large, restructuring corporation I was working in, larger projects got cancelled before they finished.
Our stuff got out and started saving them money.
When I think of MVC, I think of traditional GUI applications (either client-server or three-tier).
I don't think MVC fits as well in an HTTP get request/reply world.
YMMV.
"We can't solve problems by using the same kind of thinking we used when we created them." -- Albert Einstein
What I see alot are companies spending twice what they need to be spending because they get "sold" on either .NET or JSP.
.NET is trying to become in the worst way. Coldfusion MX is built on top of java and will run on JRun, Websphere and several flavours.
Hell. We'll take their money and give them what they want if they are stuck on a technology they know nothing about other than the "buzziness" of the acronym.
Usually we will push a client toward Coldfusion MX as an alternative. It's what
The development time is drastically cut in CFMX and it's just as capable with web services, SOAP and all the other goodies.
Karma means nothing to me, so suck it...
OK genius. Let's say you need to call the business logic you've just embedded in 3 or 4 jsps without presenting a user interface. You know, something like a batch process. What are you going to do? You're going to have to rewrite the business logic elsewhere, that's what you are going to do. Now you're screwed because you're business logic is in more than 1 place.
Not for long. You'll be layed off soon and someone rehired at half that rate, as is the fashion in the industry right now. Take a look at the new Java job postings' salaries. Not pretty.
Asp.Net is the best thing since slice bread. Your page and your code are the same. None of this, jsp page which is part java, part html, part your business logic and then pass the info to a servlet.
Why band-aid on top of band-aid.
Hmmm. But Velocity was built up BEFORE JSTL. And JSTL just tries to repare JSP problems. Velocity on the other side is neat, clean and fast. Just Give it a try to be convinced :-)
i tried it. it makes things simple but hamstrings you. i need to use 3rd party taglibs too...
sorry the future just don't look good for it.
Since inception, it seems majority of efforts of developers, and unfortunately, authors too, have been on explanation and usage of tag libraries - the tags, the EL and RT, etc. Admittedly, books on tag libraries go a step further these days and talk about taglib frameworks, like JSTL or Struts Tiles, or Cocoon (don't flame me please if i missed your favorite) and as mentioned, the segments on these frameworks tend to read more like the readme's on the websites of these frameworks - probably because the framework authors/developers spent a lot of time ensuring the framework was documented well enough for the users to be able to glean the benefits and use them!
However, there is even greater issue with taglibs that I feel goes unheeded usually. That of a taglib design. As a set, the taglibs tag form a language: the syntax is defined by the jsp spec to be XML, the elements are defined by the tag author and constrained by the taglib DTD, and the semantics (or actions) are provided by the library. So, in essence, when you create a tag library you are create a new language. I agree, in most cases, this new language will be used by the author himself (or herself), and hence little attention is paid to the semantics of the language. But, alike library/api development, with web-applications outliving their foreseen life, quite often one comes across taglibs written by others - and that's when one begins to realize the follies.
Has anyone come across or formulated a strategy for tag library design?
How does one determine the interfacing between the view helpers (or related server-side components) and tag libraries?
What problems does one encounter in tag library extensibility and customization?
What would be the potential pitfalls to watch out far?
Toting forth the vision heralded by JSP technology authors, taglibs form one of the several components, that put together, vie to separate the presentation logic from the business logic. However, I believe that last statement needs to be refactored further. We also need to separate presentation logic from view generation logic - so that the web page designers can truly create web pages without having to worry about where the script elements will be placed - so, in essence, the tag library authors will provide tags that will read like HTML (now that would be one guideline i suppose - design tag libraries on the concept of a declarative language), and the tag (or at least most of them), will be smart enough to wrap trivial expressions (the usual scriptlets to set a particular variable to calculate the colspan, for example).
Any comments?
I thought JSP referred to Jackson Structured Programming... A different JSP used in software development.
SCIREV.NET - fanfics,reviews & more
In a complex application, the amount of code that is required to go into scriptlets can quickly dwarf the amount of presentation layer stuff. I regularly have to deal with JSP files that are 3000+ lines of mangled Java, HTML and JavaScript that was written in this fashion by a consulting firm for the government. The application is supposed to be a powerful metadata management toolset for satellite datasets, but the way it was written has caused it to be so inflexible and difficult to change that it has basically had to be entirely rewritten in-house.
The real beauty of using MVC in a web application is flexibility. There's a lot of functionality that is common to numerous pages in most websites, and to avoid code duplication by using JSP includes has to be one of the messiest and most dangerous things I can think of. If multiple developers are working on the project you end up with all kinds of issues with names stepping on one another, unsatisfied dependencies, etc.
An MVC architecture is essential to any web application with any degree of complexity.
nuke the moon