Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Kevin Bronson
Greenhorn
+ Follow
2
Posts
1
Threads
0
Cows
since Oct 21, 2010
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
Ranch Hand Scavenger Hunt
Number Posts (2/100)
Number Threads Started (1/100)
Number Cows Received (0/5)
Number Likes Received (0/10)
Number Likes Granted (0/20)
Set bumper stickers in profile (0/3)
Report a post to the moderators (0/1)
Edit a wiki page (0/1)
Create a post with an image (0/2)
Greenhorn Scavenger Hunt
First Post
Number Posts (2/10)
Number Threads Started (1/10)
Number Likes Received (0/3)
Number Likes Granted (0/3)
Set bumper stickers in profile (0/1)
Set signature in profile
Search for a post/thread (0/3)
Set a watch on a thread
Save thread as a bookmark
Create a post with an image (0/1)
Recent posts by Kevin Bronson
Grizzly Jersey REST and static HTML
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.
package com.frk.jerseyrestgrizzly; import com.sun.jersey.api.container.grizzly2.GrizzlyWebContainerFactory; import org.glassfish.grizzly.http.server.HttpServer; import javax.ws.rs.core.UriBuilder; import java.io.IOException; import java.net.URI; import java.util.HashMap; import java.util.Map; import org.glassfish.grizzly.http.server.StaticHttpHandler; /** * Hello world! * */ 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.test.jerseyrestgrizzly"); System.out.println("Starting grizzly..."); return GrizzlyWebContainerFactory.create(BASE_URI, initParams); } public static void main(String[] args) throws IOException { HttpServer httpServer = startServer(); httpServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("C:\\Projects\\JerseyRESTGrizzly\\test\\"),"/test"); 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(); } }
show more
12 years ago
Web Services
Grizzly Jersey REST and static HTML
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
show more
12 years ago
Web Services