This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Services and the fly likes Grizzly Jersey REST and static HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Grizzly Jersey REST and static HTML" Watch "Grizzly Jersey REST and static HTML" New topic
Author

Grizzly Jersey REST and static HTML

Kevin Bronson
Greenhorn

Joined: Oct 21, 2010
Posts: 2
Hi All-
I have this sample project running that uses Grizzly and Jersey. The project works and serves up a REST request. I was wondering how I can also serve up static HTML from this. I have done some searching on GOOGLE but have found very little.

Here is a snippet of my code below



Thanks!
Kevin
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Of course you can serve static HTML from your service. Personally, I would think of it as a static resource in HTML format.
I would consider having some kind of handler for the root URI at which static HTML.
The handler would, when receiving a request, examine a particular directory, in which files containing static HTML are stored.
There may also be subdirectories in this particular directory, allowing for grouping of HTML resources etc.
Returning a static HTML resource is then accomplished by reading the contents of the appropriate file and returning the contents as a string.

The above is just a suggestion that I come to think of, there may be more appropriate designs for your particular scenario.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Kevin Bronson
Greenhorn

Joined: Oct 21, 2010
Posts: 2
Hi All-

I got the above project to work using this code below. This will allow me to server up a few static pages and use REST.

Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Thanks for sharing your solution!
 
Consider Paul's rocket mass heater.
 
subject: Grizzly Jersey REST and static HTML