Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/j256/simple-web-framework

Simple web framework for providing annotation based web request handling
https://github.com/j256/simple-web-framework

annotations java web-framework

Last synced: 3 months ago
JSON representation

Simple web framework for providing annotation based web request handling

Awesome Lists containing this project

README

        

Simple Web Framework
====================

Java Jetty web framework which uses the JSR annotations.

Right now the docs on this package are very minimal. My apologies. Drop me a line if you are interested in
using this and I'll get some docs, tests, and sample programs going.

Enjoy, Gray Watson

## Working Sample

Here's a little sample web program using this framework. Working sample in
SampleWebProgram.java down in src/test/java/.../example:

public class SimpleWebProgram {

public static void main(String[] args) throws Exception {
// start jetty server on port 8080
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
connector.setReuseAddress(true);
server.addConnector(connector);

// register our service with a service-handler
ServiceHandler serviceHandler = new ServiceHandler();
serviceHandler.registerWebService(new OurService());
serviceHandler.registerResultDisplayer(new StringResultDisplayer());

// set the handler on the server, this could be a HandlerList...
server.setHandler(serviceHandler);
server.start();
// you'll have to kill the jvm because of the jetty threads
}

@WebService @Produces({ "text/html" })
protected static class OurService {

@WebMethod @Path("/") @GET
public String root(@QueryParam("value") String value) {
// build a little stupid html page
StringBuilder sb = new StringBuilder();
sb.append("\n");
sb.append("

OurService Web Server

\n");
if (value != null) {
sb.append("

value is '" + value + "'

\n");
}
sb.append("

\n");
sb.append("Please enter value: ");
sb.append("");
sb.append("\n");
sb.append("\n");
sb.append("\n");
return sb.toString();
}
}
}

# ChangeLog Release Notes

See the [ChangeLog.txt file](src/main/javadoc/doc-files/changelog.txt).