users@grizzly.java.net

Re: [Jersey] Re: Grizzly Jersey REST and static HTML

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Mon, 12 Dec 2011 15:12:08 +0100

Hi Kevin,

pls. try something like this:

         httpServer.getServerConfiguration().addHttpHandler(new
StaticHttpHandler(docRootFolder), path);

where
docRootFolder is a path in your local filesystem to the folder with
static resources,
path is context root the StaticHandler will be registered to.


Hope this will help.

WBR,
Alexey.

On 12/12/2011 10:56 AM, Pavel Bucek wrote:
> Hi Kevin,
>
> please use users_at_grizzly.java.net for grizzly related questions.
>
> (cc'd, you don't need to repost)
>
> Thanks,
> Pavel
>
> On 12/9/11 11:02 PM, kevinb wrote:
>> 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
>>
>> public class App
>> {
>> /**
>> * @param args the command line arguments
>> */
>> private static URI getBaseURI() {
>> return
>> UriBuilder.fromUri("http://localhost/").port(8080).build();
>> }
>>
>> public static final URI BASE_URI = getBaseURI();
>>
>> protected static HttpServer startServer() throws IOException {
>>
>> final Map<String, String> initParams = new HashMap<String,
>> String>();
>>
>> initParams.put("com.sun.jersey.config.property.packages",
>> "com.mycompany.jerseyrestgrizzly");
>>
>> System.out.println("Starting grizzly...");
>>
>>
>> return GrizzlyWebContainerFactory.create(BASE_URI,
>> initParams);
>>
>> }
>>
>> public static void main(String[] args) throws IOException {
>> HttpServer httpServer = startServer();
>> System.out.println(String.format("Jersey app started
>> with WADL
>> available at "
>> + "%sapplication.wadl\nTry out %shelloworld\nHit
>> enter
>> to stop it...",
>> BASE_URI, BASE_URI));
>> System.in.read();
>> httpServer.stop();
>> }
>> }
>>
>> Thanks
>> Kevin
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://jersey.576304.n2.nabble.com/Grizzly-Jersey-REST-and-static-HTML-tp7079979p7079979.html
>> Sent from the Jersey mailing list archive at Nabble.com.
>>
>