Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Spring MVC requires the Servlet API </p> <p>You can create a Simple Rest Service using JSE 6 HTTP Server the following way</p> <p>You create a Resource class </p> <pre><code>@Path("/helloworld") public class MyResource { // The Java method will process HTTP GET requests @GET // The Java method will produce content identified by the MIME Media // type "text/plain" @Produces("text/plain") public String getClichedMessage() { // Return some cliched textual content return "Hello World"; } } </code></pre> <p>You create an Rest Application </p> <pre><code>public class MyApplication extends javax.ws.rs.core.Application{ public Set&lt;Class&lt;?&gt;&gt; getClasses() { Set&lt;Class&lt;?&gt;&gt; s = new HashSet&lt;Class&lt;?&gt;&gt;(); s.add(MyResource.class); return s; } } </code></pre> <p>And that's how you start your Server</p> <pre><code>HttpServer server = HttpServer.create(new InetSocketAddress(8080), 25); HttpContext context = server.createContext("/resources"); HttpHandler handler = RuntimeDelegate.getInstance().createEndpoint (new MyApplication(), HttpHandler.class); context.setHandler(handler); server.start(); </code></pre> <p>That's all. No Spring MVC required.</p> <p>For Testing purposes this works very well, for a productive usage with many requests I would use a WebContainer like Jetty or Tomcat.</p> <p>A more detailed description of how to build a RESTFul using the Standard JSE 6 HttpServer can be found <a href="http://it-republik.de/jaxenter/artikel/RESTful-Web-Services-mit-JAX-RS-4136.html" rel="nofollow">RESTFul Webservice mit JAX-RS</a> (German) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload