How to implement REST in a web application?

I want to know how to implement REST in my web application. I want to create a web application based on this service, but I do not know how to do it. Now I use J2EE and Tomcat. What things should be considered for these technologies?

EDIT: Sorry, I mean the RESTful service.

+6
java-ee rest web-applications
source share
5 answers

REST is not a specific interface or technology, but a style. The best example is the web browser itself - your browser sends an HTTP request to a web server that responds with a web page.

The transfer of presentation state in this context: the presentation is a web page, the state is the information contained in it. We could change the view by switching to xml service instead of html, but the information would be the same.

In the RESTful service, you use this style to send data back and forth - the state is sent from the server to you, and then you send the new state back.

So, in a sense, Tomcat will already do REST for you if you put your server pages as resources: http://carsales.com/cars/porsche2149 there may be a resource for your car that you could use HTTP POST or PUT to to change its details.

REST keys use URIs to denote resources, as described above, using JSON or XML as the medium of exchange (although AHAH and other formats are used), as well as how to delete collections.

First, find out what your resources will be and organize your URI system (use URL rewriting, etc.). Then determine the view (s) you want to use. Finally, write a backend to deal with messaging state views around and update the database.

+12
source share

I have no experience with CXF jax-rs, but Restlet works fine for me. This allows RESTful and customer services in a simple manner. This really helped me with programming regarding the DekiWiki REST service interface. There is O'Reilly's book, RESTful Web Service, which gives a good presentation. It also has a short section in Restlet.

+1
source share

This is a bit of an answer to the disk, but if you want framework / api to help here, these are two options:

Restlet

CXF jax-rs

0
source share

We also use Restlet with JAX-RS.

If you intend to use JAX-RS (Java API for RESTful Web Services), then this document may be useful (although this is a reference guide for development in JBoss RESTEasy).

I also recommend a REST client test

0
source share

RESTful Web Services is a book that can help you. It describes the incentive for RESTful web services and gives instructions on how you should design your service. Then you can move on to implementation using either the framework or simply with servlets.

As an alternative to the implementation methods already mentioned, I would like to add Spring MVC. You can create RESTful applications already , but more direct support will be added in Spring 3.0

0
source share

All Articles