Jetty RESTFul Web Service

Jetty RESTFul Web Service

In last tutorial you saw how to create Jetty server and integrate Servlet with it. If you want to create full fledged RESTFul web service with Jetty you can create it easily, although many choices are there and I will Jersey with Jetty to create RESTFul web service.

  • Create maven project name: JettyRESTFulWebService as full project structure shown below:

Jetty RESTFul Web Service

  • pom.xml:

  • JettyServer.java:

RESTFulResource.java:

  • Model class: Person.java:

  • To test MediaType.APPLICATION_OCTET_STREAM from java you can use HttpClientPostTest.java:

  • To test XML data you could use: XMLClientTest.java:

  • That’s it. To test this application start JettyServer as java application and mentioned in RESTFulResource.java, we have created multiple resources for HTML, XML, JSON, APPLICATION_OCTET_STREAM and you can test easily with any RESTful tools I have used Postman below are some outputs:

Jetty RESTFul Web Service

Jetty RESTFul Web Service

  • For more information please visit Jetty documentation here

download Download Project: JettyRESTFulWebService

One thought on “Jetty RESTFul Web Service

Leave a Reply

Your email address will not be published. Required fields are marked *