users@jersey.java.net

Re: returning an HTML page

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 1 Dec 2010 16:03:29 +0100

On Nov 30, 2010, at 7:26 PM, Arthur Yeo wrote:

> All,
>
> In the event that a WS call needs to return a full HTML page, is it
> a common practice to concat the whole page piece-by-piece into a
> String and return it?
> Or is there a better way to do this?

A recommended and conventional approach to this problem is to use
templates.

There are many template libraries and formats to choose from. Jersey
supports JSPs out of the box. The scalate framework integrates with
Jersey to support the various set of scalate templates. Someone has
written Freemarker support too,

See the following example to get a better idea:

   http://download.java.net/maven/2/com/sun/jersey/samples/bookstore/1.4/bookstore-1.4-project.zip

Paul.