There are lots of reasons why this is not the way to code JSPs, Dola. 
Let's start with one: REUSABILITY.

If I can read "between the lines" in your code, you are essentially
using these classes to write HTML in sort of a Tiles way.  This is
clearly a good thing and your ideas might be really worthwhile.  That
is not at issue in what I have to say.  I am also not, at the moment,
talking about the <%= whatever %> expression code, but rather only 
the <% whatever %> scriptlet code.  You don't use <%! whatever %.
declaration code.

The only way to reuse the code you wrote is to copy and paste.  (Often
this is called "cut and paste" which makes no sense.)  If you
consolidated and generalized the code off the page in some, say,
Process class, then you could have something like <%=
Process().process([whatever]) %> where "whatever" represents what is
peculiar to this page alone and what is common to all like pages is
included in the off-JSP-page Process process method code.

If you only made this change, then your page person, which might be
the same person, would only have to write

<%= Process.process([whatever]) %>

on each page and would not have to write the code elsewhere either
because that would already have been abstracted and done.

If we cannot all agree this is progress, then we probably cannot agree
on the whole idea of getting code off the page at all.

I also like what Tim had to say because he recognizes that sometimes
we have to write the particular code and abstract later as a business
decision.  However, he does it in a way that recognizes that adhering
as close to the principles of OOP as possible will make the later
transition easy when duplicating code becomes an issue.

I hope this helps.  Let me say that I find that the principles of OOP
can be defended and need not be adhered to out of blind faith.  It is
better to find out what is up than to just follow the dictates of
whomever.  Once again, good question.  I hope this engenders a long
and useful thread.  If it did, we could save a lot of "ink" on the
list.

Jack


On Sun, 23 Jan 2005 07:07:21 -0800 (PST), Dola Woolfe
<[EMAIL PROTECTED]> wrote:
> I just read this thread and didn't quite understand
> it. If it means what it seems to mean on the surface,
> I'm doing everything wrong.
> 
> Schematically, my typical JSP page looks like the
> following (basically 100% code). Is this what Craig is
> advising against?
> 
> <%@ page errorPage="ErrorPage.jsp" import="html.*"%>
> <[EMAIL PROTECTED] file="InitializePage.jsp"%>
> <%
>     Table table = new Table()
>     .pAddH("#").pAddH("Action").pLN()
>     .pAddC("1").pAddL(new Anchor("HelloPage.jsp", "Say
> hello to my friend.")).pLN()
>     .pAddC("2").pAddL(new Anchor("GoodByePage.jsp",
> "Say good bye to my friend")).pLN()
> ;
> 
>     MyTemplate template = new MyTemplate ("Main
> Actions", table);
>     Page pAgE = new Page(new MyHead("Data Tools"), new
> Body(template));
> %>
> 
> <%= pAgE %>
> 
> __________________________________
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
> http://promotions.yahoo.com/new_mail
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
------------------------------

"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to