 |
Are you using JSTL as you should?
Posted by mister__m on August 26, 2003 at 11:04 AM | Comments (13)
"Java is indeed very powerful, flexible and scalable, but it is pretty hard to do simple things with it!" " is far more practical to this job than Java" "We should only use Java to more complex tasks" "There is no point in using Java if your product is going to be small" Have you ever heard any of these sentences before? You probably have. And I have to agree some things are just too hard to do using plain J2EE out-of-the-box web components - I mean, using JSP/Servlets only.
When it comes to most web applications requirements, it is been just unnecessarily too difficult to implement simple stuff. But this dark era has come to an end with JSTL.
JSTL is a set of tag libraries, some validators and a cool feature that also is going to be part of JSP 2.0, the Expression Language - EL - which will improve your productivity considerably. Accessing complex bean structures, handling logical expressions, looping through arrays, collections etc., processing XML, executing SQL instructions in transactions and more - all those things are made easy by JSTL. Although some features are debatable - tags that allow you to execute SQL code inside your JSPs, for example - they can be used for some useful purposes - prototyping, for example.
For example, a few weeks ago, someone asked me how hard it would be to connect to a URL, forward a few parameters, read back the result stream and display the data returned to the user. My first thought was to say it would take a few lines of code and a couple of minutes to write and test, but then I remembered the tag from JSTL. Well, it took seconds to write and test! That is a productivity boost! Writing reliable, tested Java code in seconds - that is something your IT manager would like to hear :-)
So, if you don't know JSTL, go to URL above or visit http://java.sun.com/products/jsp/jstl/ if you want to know more about it. Believe me, you should :-).
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
I Agree with you.
Hello Michael,
Really for those that use only the Servlets/JSP technologies in some projects, can increase significantly the productivity using the JSTL and even though building your own custom tags.
So is really a great idea spend some time and learn more about the JSTL.
Posted by: mpietro on August 28, 2003 at 05:40 PM
-
What about Struts tag libraries ?
How do you compare JSTL with Struts Tag libraries ?
Posted by: prak on September 03, 2003 at 04:23 PM
-
JSTL VS normal JSP
i prefer normal JSP style.. coz adding JSTL will generate a lot of servlet code in Tomcat, and i feel JSTL is quite difficult to learn, since we know java, y don't just use normal JSP scriplet ?
Posted by: kokchoon78 on September 04, 2003 at 03:27 AM
-
struts-el
A lot of the function of the Struts tags is duplicated by tags in the JSTL, plus you can't use the (very nice) JSTL Expression Language with bog-standard Struts tags. However, struts is definitely moving towards support for JSTL, and if you look in the 'contrib' directroy of Struts 1.1, you can see that a very ususable set of replacement, EL-friendly, tags has been provided.
Roberto
Posted by: robertotyley on September 04, 2003 at 05:07 AM
-
A bit danger
I have discoverd JSTL early summer this year while working on simple Web UI. Since I found myself avoiding servlets in role of MVC controlers in favor of "controler" jsp equipped with JSTL. While this gives me faster development - no need to restart context , less coding - this would also prevent me from effecient refactoring, inheritance and so on... But it is just so easy ....
Posted by: vtec on September 05, 2003 at 04:25 AM
-
Less is more. We don't need this!
Only a fool values complexity when
simplicity will do.
Adding a new java web scripting framework,
no matter if it itself is simple, to the already
available jsp framework is adding complexity
to the java frameworks taken as a whole.
As someone said, people who want to use
java for dynamic websites already know java,
so JSP, wisely used, is fine.
James Gosling knew the value of parsimony
in language and framework design. Someone
is slipping up now. I don't think adding JSTL
to the mix is progress, for the simple reason
that its simplifications are questionable and
it in itself just adds complexity to the whole
picture of java and dynamic web-app
construction. Not a good judgement call
IMHO.
Posted by: hawthornee on September 09, 2003 at 12:55 AM
-
Less is more. We don't need this!
Sun's website this summer posted recommendations that JSP pages contain little to no java code. How else do you write a JSP page you ask? JSP Custom Tags are the answer. Simple, Testable components (unlike script heavy JSP pages) that improve productivity by allowing a larger set of developers work with Java. believe it or not, not EVERY web designer needs/wants to know java. With JSP Custom tags (JSTL included), all you need to know is valid HTML or XML syntax. yes it is "another language", but it opens the doors to Java Developers to write JSP custom tags and Web developers to use them!
Posted by: wireframe on September 09, 2003 at 08:11 AM
-
Less is more. We don't need this!
Only a fool values complexity when
simplicity will do.
That's exactly why JSTL was concieved. It simplifies many of the repetitive tasks that most web developers face. I would suggest you look at some of the various articles on IBM developerWorks and other Java sites and see for yourself how easy JSTL really is to learn and use.
Another added value is that in most web development groups, you have people who do back end coding and people who focus in the UI. Usually the people who focus on the UI know little or nothing about how to program and scriptlets can cause problems for those people. JSTL tags are very simple to use by people who don't know alot about Java and also keep the page source much cleaner for them to focus on layout and graphics.
Posted by: jackass on September 09, 2003 at 12:39 PM
-
Complexity
I think it is a good thing. It will make apps easier to develop.
This promotes reusability. All the common code for connecting to a server on a port, sending a request and getting the response can be wrapped cleanly for other developers to use.
Posted by: ___ on September 10, 2003 at 12:12 AM
-
Layer separation -- a conceptual discussion
Hi! Michael
As everything in life, it's not possible to earn always and forever.
When one instruments JSP in a such level like to execute a SQL Select then one is breaking the concept of separation of layers. You've mentioned "for prototyping purposes"... but, how many other shortcuts can one add to JSP that will finally ends up breaking separation of layers?
For a very simple prototype it maybe usable and productive. But, for large scale J2EE applications, separation of layers is very important to achieve needed performance, security and scaleability.
Besides, presentation layer is for web designers... that guys with long hairs and few marijuanas in the pocket. These guys don't like programming and don't intend to. They even hate programmers because programmers use short hair and thick glasses.
I'm saying that there's a big problem with big scale websites, specially those that need to change look and feel by the time; you have to make web designers and programmers work on the same code base, the HTML code. Web designers are able to produce stunning pages, but hate and don't know scriptlets/taglibs; programmers know scriptlets/taglibs but hate graphic design and colors.
To accomodate these two different approaches over the same code base, a Jakarta hosted project named Tapestry aims to offer a solution. It's a totally different approach if conpared to JSP. Using Tapestry, the web designer can create a prototype using ordinary page composition tools; the programmer can instrument the HTML file for dynamic content and the final HTML file can be opened again by page composition tools for design adjustments. This approach allow web designers and programmers to work together in a team.
The Tapestry's lead architect even have already written in TheServerSide something like "JSP is the biggest design mistake done by Sun" and completes with "Sun followed Microsoft's ASP and have made a big mistake as well".
Unfortunately, Tapestry is still imature and there's no published books about it, but it surely deserves our attention!
Returning to your article... I agree that JSTL and other techniques may lead to huge productivity gains. But, in concept JSP is a big mistake in the presentation layer because it brings on more problems than solutions. As Microsoft's ASP does.
Fernando Gomes
mailto:fernando.gomes@bigfoot.com
[Sao Paulo, Brazil]
Posted by: frgomes on September 10, 2003 at 04:14 PM
-
The way we used JSP successfully
Was to specify the pages to the
web creatives, take their draft page,
substitute in simple jsp expressions like
where needed,
add a standard header and footer
jsp include (1 line at top and bottom of
html file) for session initialization
and error handling, and maybe
have a few variable-setting
lines wrapped in
or
at the top of the file above
Then we said to the graphics and
html whizzes. Don't touch the
stuff inside the symbols.
Oh, and it might vary in size in the
following amounts.
It seems pretty simple to me.
Sure, it's nice to have standard
conventions for how to use the database,
or verify session login, etc, but you don't
need anything more than some
judiciously used POJOs (plain
old java objects) to handle that.
Posted by: hawthornee on September 13, 2003 at 09:57 AM
-
What I object to in Tag Libs is the constant reintroduction of control logic. I dont mind adding a new way of creating a table or printing a header. But the fact that we are reinventing if, while, and for defies my understanding of what Java was built for. Java is a language which defines how we manipulate data and control program flow. It does it exceedingly well. Why then, must we constantly reinvent our control structures? We know how to use if, while, and for. As an example, JSTL offers us <c:if> but no <c:else>. And even if it did, what is wrong with using Java's native if? It wouldnt be so bad if the JSTL library were generic enough to handle all control flow issues, but we see <x:if> as well. and it surfaces in Struts tag libs.
We have a very good way to handle control flow in Java, let's use it.
Posted by: devcybiko on October 13, 2004 at 11:10 AM
-
Sir,
I have use display tags to design a dynamic tables in jsp.
But How I want to wrritten the Tag handler Classes in Display table.
In My projects i get the input from the NetworkDAO (getting user ID, Network Type, Description, Information) and I want to display in Tables.
Posted by: achappan on September 05, 2006 at 08:23 AM
|