Quoting Marty Halvorson ([EMAIL PROTECTED]):
> >2- Create an HTML template with own-defined tags so that when this page is
> >requested, the servlet is called, read the template and replace all the
> >own-defined tags by the appropriate values.
>
> Solution 2 is far and away the best.  Just read the file containing the
> html inside the servlet, replace the data, and send the result.

There are lots of systems that do this for you already so rather
than writing your own you should use an existing one. WebMacro
(www.webmacro.org) is an example of one, there is also FreeMarker
and a couple of others, all of which provide more functionality than
you would likely implement yourself.

WebMacro in particular can use ordinary Java classes as the input to
the template--it uses bean style analysis to work out what the
relationship is between the values in the template and the properties
of the objects you supply.

You just drop an object into a hashtable like this:

    context.put("customer", new Customer("Fred", "555-1212", ...));

and then in the template you can write

    $customer.Name has phone number $customer.Phone

and WM works out that you meant Customer.getName() and Customer.getPhone().
It also supports looping through arrays and lists of objects in a
similar fashion.

Justin

___________________________________________________________________________
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