JAX – RS @ApplicationPath Annotation(no web.xml) Example in jersey

In this tutorial we will learn how to develop a restful web services application with out web.xml. We have an annotation @ApplicationPath provided by JAX – RS which is used to achieve this. This can be used only in above servelt3.0 complaint containers (ex:Tomcat7 …).

let us have a small example.

1. Create Dynamic web project in Eclipse.

RestfulApplicationPathAnnotationExample_project

2. Write Java Resource classes.

 

3. Write a configuration class instead of  web.xml

 

4. Run the Example

NOTE : I have not included all the required jersey jars in the source code please download it from here and copy to lib folder.

OUT PUT:

hit the url http://localhost:8080/RestfulApplicationPathAnnotationExample/resources/hello   we will get below output.

RestfulApplicationPathAnnotationExample

 

 

Download  Source Code

Posted in webservices and tagged , .

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">