This example demonstrates a simple Link Shortener webapp demonstrating Jersey MVC and Bean Validation capabilities. There is no validation on the frontend side, every error displayed is recognized on the backend.

Contents

The mapping of the URI path space is presented in the following table:

URI path Resource class HTTP methods Allowed values
/ ShortenerResource GET, POST  
/r/{link} ResolverResource GET link - shortened link part
/i/{link} PermanentLinkResource GET link - shortened link part

Application is configured by using web.xml, which registers javax.ws.rs.core.Application extension to get classes and singletons from it (see class ShortenerApplication). MVC and Bean Validation annotations are present on resource classes (see ShortenerResource, ResolverResource, PermanentLinkResource) as well as on the domain class (see ShortenedLink).

Running the Example

Run the example as follows:

mvn clean package jetty:run

This deploys current example using Jetty. You can access the application at http://localhost:8080/

Resources

This examples is using following (3-rd party) front-end frameworks:

Mustache.java by spullara - templating engine
Bootstrap by Twitter - front-end HTML/CSS/JS framework