tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject RE: JSP help: A bit off topic
Date Fri, 03 Jan 2003 19:51:00 GMT

>  myObject.getSomeString() /* This will actually contain all the code in
>  JSP, just to avoid the JSP page cluttered with Java Code */

If you expect getSomeString() to return *JSP* code (including tags and
scriptlets and all), you can't do that.  The JSP code is compiled the
first time you execute this page -- you can't create it dynamically at

At best, you could have getSomeString() return some static HTML code and
write it to the output stream:


However, embedding *any* of this stuff is really a misuse of the
technology, because you end up intermixing business logic ("what data am
I manipulating") with presentation logic ("how do I want this data to
look") in ways that will lead you into unmaintainable spaghetti code that
is very difficult to update later.

A far better strategy is to use some sort of MVC architecture (such as
Struts, and put your business logic in
Java classes, and your presentation logic in your JSP pages or whatever.
Let your business logic deal with the *data* (getting it from the
database or whatever) and your JSP page deal with the *UI* (how it appears
to the user).


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message