>>> Richards Ryan <[EMAIL PROTECTED]> 21-Jun-00 10:39:35 PM
>>>

>I have a servlet that reads in a static html page and
>displays it via an app/web server. I am aving no problems
>with this part except that I would like to move a step
>further and dynamically generate a populated selection
>box with items retirieved from a database. I have done
>all these bycoding the html tags in a servlet but I would
>like to read in my static 'template html' files and
>REPLACE/SUBSTITUTE some marker with the generated
>tags i.e. <OPTIONwhatever1</OPTION>
>What is the best practice for using substitution in a static file?

Firstly, if you';re doing this the file is no longer a static file.
It's now a template.


>SHould I create some marker like '#replaceme#' and have
>the servlet change that to the required html tags??

I recomend using a JSP page, or some template engine.


If you use a template then you have to parse the file each time you
want to display it. That takes time.

You also have to implement your own parsing system, based on a
tokenizer or a regexp.

With JSP the file gets compiled once - to a servlet and you can have
anything you want displayed in the OPTIONs. It is vastly faster than
reading the file, parsing it, replacing the markers and then outputing
it.

A template engine (such as WebMacro) would be just as good (at least
for a simple job like this).


Nic Ferrier

___________________________________________________________________________
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