/rest101

A basic project to get you started with Jersey

Primary LanguageJava

REST101

A basic project to get you started with Jersey.

We can get responses in plain text and JSON. We can also store and retrieve JSON via HTTP to a MapDB.

How to create the base archetype:

mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 -DarchetypeGroupId=org.glassfish.jersey.archetypes -DgroupId=de.gb -DartifactId=rest101 -Dpackage=de.gb.rest -DarchetypeVersion=2.25.1

How to run

mvn clean package exec:java

Where to find your resource in plain text?

curl -v -H "Accept:text/plain" http://localhost:8080/myapp/gotit

Or make your browser go to: http://localhost:8080/myapp/gotit

Where to find your resource in JSON?

curl -v -H "Accept:application/json" http://localhost:8080/myapp/gotit

How to PUT JSON

curl -v -X PUT -H "Content-Type:application/json" -d '{"message":"Hello World"}' http://localhost:8080/myapp/gotit/1

How to GET JSON back

curl -v --header "Accept:application/json" http://localhost:8080/myapp/gotit/1