tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Hartung" <wi...@msoft.com>
Subject Re: is there a tag or some kind of mechanism that would do the following ...
Date Tue, 25 Feb 2003 22:19:26 GMT
> From: "Karr, David" <David.Karr@wamu.net>
> Sent: Tuesday, February 25, 2003 1:53 PM
> Subject: RE: is there a tag or some kind of mechanism that would do the
following ...


> I'd say your best strategy is to approach this problem from a different
> direction.  Instead of figuring out how to make it easy to emit HTML
> from your servlet, work on building JSP custom tags which emit small
> logical pieces, and then reference those tags from your JSP pages.

That could work, if the code was used enough to make reusing it viable.

It's one of those fine lines between a JSP and a Servlet.

Another thing that could be done is simply writing a local class method:

private void p(String s)
throws IOException
{
    out.println(s);
}

Then, your code becomes:
p("<html>")
p("<title>")

etc. That can help simply reduce the boiler plate of printing it out.

Finally, I'd look at creating a simple script is any convenient language
that simply converts an HTML file into "java", and then cut-n-paste in into
your code.

Now, I find cut-n-paste to be one of the great evils of the development
communiity, but sometimes it is appropriate for one-off "code generation"
tasks.

If you keep the original HTML around, then you don't have to worry editing
in place, simply edit the master, run the filter, and re cut-n-paste.

Here's a simple sed(1) script:
sed -e 's/"/\\"/g' -e 's/.*/out.println(&)/g'

Regards,

Will Hartung
(willh@msoft.com)




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message