views:

166

answers:

6

I would like to create a web server that will serve/accept json files through REST. The JSON files being served will come from a database query and format the results into JSON. Any suggestions for a good java library. I have tried using Apache HTTPComponents. While maybe I can just create a servlet but I am not really allowed to install a servlet container in the server machine.

EDIT: I was just thinking to create the program where I can just simply issue a simple java -jar Application.jar and everything is already started and functional. The application will listen on a certain port of the machine and respond to some requests from browser and/or another java program. Looks like Jetty will help me do it. As I have said, I have implemented something using HTTPComponents and I'm just simply parsing the URL from the requests and do something in the server based on the parsed URL.

+1  A: 

I'm a huge fan of the venerable Jetty. It's small and straightforward. It's technically a servlet container (it's more thought of an embedded HTTP server), but you can embed it within your own app. It also supports Java REST libraries such as Jersey

Jason Nichols
A: 

You might want to have a look at Restlet: Restlet Tutorial

Bakkal
+1  A: 

CXF is a fantastic web services library. It has built-in support for REST, but I haven't tried that particular feature myself. CXF uses Jetty by default, but it's designed to be easily adaptable to Tomcat or other servlet containers.

Chris Dolan
Nice, I haven't tried CXF before...
Jason Nichols
A: 

Check out Grizzly project

Greg
A: 

Do you really need all the overhead and complexity of a web server? It sounds like all you really need is a socket listener.

TMN
A: 

I would suggest having a look at:

What I like about them:

  • Both of you can be run embedded (as jar).
  • They also both support an "asynchronous event-driven"/NIO architecture. Jetty has continuations for this. NIO is the new way of handling IO and has the ability to scale better.
Alfred
Do you thing Jetty will be a good choice? and maybe use RESTlet to implement the RESTful web service?
dexter
I think you could both implement REST on Jetty and Netty. My first choice would be netty to be honest. I have been playing a lot with it lately and I like it a lot. Small footprint and really fast. But Also Jetty is a really good package. A lot of big company's use Jetty. Google's java app engine runs on Jetty for example. Implementing REST interface is for most part I think about discipline. Documenting your API well. But Netty/Jetty support GET/PUT/POST/DELETE semantics(easily) which are neccesary to implement REST API/interface.
Alfred