Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

jsp vs template engine

Thread view: 
Lancelot Mak - 29 Dec 2004 07:26 GMT
hi, experts

just wondering if we have jsp already........
then why would we need template engine?
may any experts share some insights about template engines? velocity,
freemarker.....etc
since i m going to develop an app using MVC (struts)......just wanna
know if i should use jsp or template engine as the V

thanks
lancelot
Josh Martin - 29 Dec 2004 07:36 GMT
Lancelot -

I've seen alot of folks stating that templating engines can significantly
reduce your code.  I definitely agree to a point.  I use Velocity to
generate SQL and email messages for me, but not my end pages.  Struts is
still much more closely paired with JSP and with EL (Expression Language) in
JSP, there really isn't a huge benefit to using Velocity as and
"HTML-renderer".  The only difference is a pair of brackets - $something
(Velocity) vs. ${something} (EL in JSP).

Josh

> hi, experts
>
[quoted text clipped - 7 lines]
> thanks
> lancelot
Tony Morris - 29 Dec 2004 09:58 GMT
> hi, experts
>
[quoted text clipped - 7 lines]
> thanks
> lancelot

Templating engines allow you to write testable code.
JSP requires you to use mock objects or some other less elegant technique.

Struts is a very crusty framework.
Consider Spring, WebWork or JSF.

Signature

Tony Morris
http://xdweb.net/~dibblego/

Josh Martin - 29 Dec 2004 15:21 GMT
> Templating engines allow you to write testable code.
> JSP requires you to use mock objects or some other less elegant technique.
>
> Struts is a very crusty framework.

Tony - could you provide some examples of JSP's "untestable" nature and how
Struts is "crusty"?
Chris Smith - 29 Dec 2004 16:34 GMT
> > Templating engines allow you to write testable code.
> > JSP requires you to use mock objects or some other less elegant technique.
[quoted text clipped - 3 lines]
> Tony - could you provide some examples of JSP's "untestable" nature and how
> Struts is "crusty"?

I'm not Tony, but I'll jump in.  It is a substantial problem that it's
difficult to test JSP code outside of a web application.  This doesn't
prevent code from being tested, but it makes running unit tests on page
generation much more difficult to set up (specifically, you have to
either use mock objects, or start up a servlet container and run your
unit tests by making HTTP connections to the server).

This stems mostly from the fact that the interface between JSP and its
surounding context is far more complex, and assumes the availability of
an implementation of the entire servlet API.  Most non-JSP
implementations, on the other hand, require that the application
explicitly hand information to the page, and don't allow the page
unbridled access to to the entire servlet framework.  That means it's
easier to set up a fake context for testing.

I can't speak for what Tony has against Struts.  There are certainly
things about Struts that are a pain, but Tony has expressed
disproportionate hostility toward Struts on several occasions here, and
I could only guess at the reasons.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Tony Morris - 29 Dec 2004 23:50 GMT
> > Templating engines allow you to write testable code.
> > JSP requires you to use mock objects or some other less elegant technique.
[quoted text clipped - 3 lines]
> Tony - could you provide some examples of JSP's "untestable" nature and how
> Struts is "crusty"?

Here is a short, incomplete list:
- Struts is programmed to an abstract class, presumably because the author
(who is now on the JSF team) didn't know what an interface was (hopefully
does now) - this is one of many common antipatterns used by C++ programmers
attempting to use their preconceptions in Java.
- Struts is tied to the web containter; increasing coupling, reducing
testability - this is unnecessary from a MVC framework (there is a lot more
to this already won argument that is documented elsewhere).
- Struts Actions must be thread-safe due to the fallacy that object creation
is expensive (another C++ holdover).  Typically, Actions hold no state and
are lightweight so the issue of thread-safety should be delegated to the
developer of the Action, not the framework.

Once you have used WebWork or Spring, the issue of 'crustiness' (or your
preferred terminology) should become more apparant, at least, it did for me.
I vaguely recall an article where the author of Struts acknowledged the
crustiness (I don't remember any more details - I may have even read it in a
book or imagined it).

Signature

Tony Morris
http://xdweb.net/~dibblego/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.