[[Jakarta_RESTful_Web_Services_Reference_Guide]]
= Jakarta RESTful Web Services Reference Guide

This page outlines the three options you have for deploying Jakarta RESTful Web Services
applications in WildFly {wildflyVersion}. These three methods are specified in the
JAX-RS 2.0 specification in section 2.3.2.

[[subclassing-javax.ws.rs.core.application-and-using-applicationpath]]
== Subclassing javax.ws.rs.core.Application and using @ApplicationPath

This is the easiest way and does not require any xml configuration.
Simply include a subclass of `javax.ws.rs.core.Application` in your
application, and annotate it with the path that you want your JAX-RS
classes to be available. For example:

[source,java,options="nowrap"]
----
@ApplicationPath("/mypath")
public class MyApplication extends Application {
}
----

This will make your Jakarta RESTful Web Services resources available under `/`
`mywebappcontext` `/mypath`.

[WARNING]

Note that that the path is `/mypath` not `/mypath/*`

[[subclassing-javax.ws.rs.core.application-and-using-web.xml]]
== Subclassing javax.ws.rs.core.Application and using web.xml

If you do not wish to use `@ApplicationPath` but still need to subclass
`Application` you can set up the Jakarta RESTful Web Services mapping in web.xml:

[source,java,options="nowrap"]
----
public class MyApplication extends Application {
}
----

[source,xml,options="nowrap"]
----
<servlet-mapping>
   <servlet-name>com.acme.MyApplication</servlet-name>
   <url-pattern>/hello/*</url-pattern>
</servlet-mapping>
----

This will make your Jakarta RESTful Web Services resources available under `/`
`mywebappcontext` `/hello`.

[NOTE]

You can also use this approach to override an application path set with
the `@ApplicationPath` annotation.

[[using-web.xml]]
== Using web.xml

If you don't wan't to subclass `Application` you can set the Jakarta RESTful Web Services
mapping in web.xml as follows:

[source,xml,options="nowrap"]
----
<servlet-mapping>
   <servlet-name>javax.ws.rs.core.Application</servlet-name>
   <url-pattern>/hello/*</url-pattern>
</servlet-mapping>
----

This will make your Jakarta RESTful Web Services resources available under `/`
`mywebappcontext` `/hello`.

[NOTE]

Note that you only have to add the mapping, not the corresponding
servlet. The server is responsible for adding the corresponding servlet
automatically.

NOTE: References in this document to Java API for RESTful Web Services(JAX-RS) refer to Jakarta RESTful Web Services unless otherwise noted.
