Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Grizzly Jersey REST and static HTML

 
Kevin Bronson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Kevin Bronson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing your solution!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic