Why re-invent the wheel? It's true that systems like WebMacro
(www.webmacro.org) have a lot more advanced functionality than
this, but you don't have to use it. You could just do this:

    Hashtable h = new Hashtable();
    h.put("news", "The news for today...");
    Template t = new FileTemplate(path); /* contains ... $news ... */
    String result = t.evaluate(h);

Sure you could have done a lot more with the template than that, but
nobody says you have to. I'm sure other template systems can be used
in similarly dumbed down ways.

That accomplishes everything you're trying to write, I think.

Justin



Quoting Jay Macarty ([EMAIL PROTECTED]):
> Balogh,
> I like the idea of the simple templateReader class and have, in fact, been
> trying to develop one of my own. From your example I like the way your class
> works and was wondering if you might consider sharing the source with me by
> sending a private Email?
>
> -----Original Message-----
> From: Balogh Andras <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Tuesday, August 10, 1999 3:35 AM
> Subject: Re: out.println(".....");? There's STILL no better way
>
>
> >        Hi Peter,
> >
> >        I understand Your anger about out.println.
> >Here are some ideas:
> >Write a small Java apl that takes a text from a file
> >and does the following:
> > -You can do a replace all " with \" .
> > -put at every line out.println(" at the begin and ") at the end.
> >
> >Than You will have a file that contains the out.println s and copy it into
> >your source.
> >
> >This in case that You DON'T want to deal with any templates.
> >BUT sooner or later You will find out that if changeings in design
> >will produce as result to modify EVERY page that is generated using
> >Servlets.
> >And changings in DESIGN ar very likely to produce every month
> >(in this changeing world).
> >So here is how i work:
> > I have created a TemplateReader class that  supports reading a template
> >(HTML file) with comments marking zones like this :
> ><!--beginnews-->
> >News
> ><!--endnews-->
> >
> >My servlet takes this template and fills out the dinamic part (news) and if
> >the page design should be changed it can be done only the comments are to
> be
> >kept.
> >The servlet source looks like this:
> >
> >....
> >StringBuffer news=new StringBuffer();
> >news.append("Today's news as follows:...");
> >
> >TemplateReader template=new TemplateReeader(pathtotemplatefile,true);
> >template.addReplaceAllRule("
> ><!--beginnews-->","<!--endnews-->",news.toString() );
> >template.addReadRule("</html>");
> >template.returnProcessedTextTo(out);
> >templat.close();
> >out.close();
> >.....
> >
> >As You can see no out.println()  :-))
> >
> >I have tought that webmacro, freemaker etc. are too complex to be used
> >by me. If my project will reach a more advanced stage i will use them.
> >So because this TemplateReader was written by me i know at every stage what
> >happens exactly.
> >You can write Your own TemplateReader.
> >
> >p.s. If this message was boring or doesn't interst You press DEL.
> >
> >Best wishes,
> >                    Andras
> >
> >
> >----- Original Message -----
> >From: Peter <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Monday, August 09, 1999 6:26 PM
> >Subject: Re: out.println(".....");? There's STILL no better way
> >
> >
> >> I totally agree ........ my code would've been around 60 kb if it wasn't
> >for
> >> these out.println and the need to put the escape character \ on every "
> in
> >> the HTML output. Yukkkss!!!!! Thanks to all these tiresome and
> >unneccessary
> >> (correct spelling ?) out.println formatting, the code is now close to 130
> >> kb. And that's after using a StringBuffer object to avoid typing
> >out.println
> >> for every HTML line.....................
> >>
> >> Ohh and if anyone comes up with a reply that contains the word
> "webmacro",
> >> "freemarker", "ecs" and all that template/jsp crap, may you rot in
> hell!!!
> >>
> >> Please all you open source java gurus, put us servlet developers out of
> >this
> >> println misery!
> >>
> >
> >___________________________________________________________________________
> >To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> >of the message "signoff SERVLET-INTEREST".
> >
> >Archives: http://archives.java.sun.com/archives/servlet-interest.html
> >Resources: http://java.sun.com/products/servlet/external-resources.html
> >LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to