Java Reference
In-Depth Information
The servlet will respond with a static HTML page (we defined the content type as Text/
HTML with an UTF-8 charset) for every GET HTTP request that will be issued against its
URL address.
Note
Notice that TextServlet bears the @WebServlet annotation, which has been intro-
duced by the Servlet 3.0 API, and it allows registering a servlet without using the
web.xml configuration file. In our example, we used it to customize the servlet URL
binding to employ /test , which would otherwise be defaulted by Eclipse to the class
name.
We will complete the application with the creation of a JBoss file descriptor named
jboss-web.xml in /WebContent/WEB-INF/ directory; although this is not
mandatory, it can be used to redefine the context root, as shown in the following code
snippet:
<jboss-web>
<context-root>/hello</context-root>
</jboss-web>
Note
The schema definition file for jboss-web.xml is named jboss-web_8_0.xsd and
can be located in the JBOSS_HOME/docs/schema folder.
Keep in mind that creating jboss-web.xml makes the application non-portable to oth-
er Java EE Application Servers. The default application path when such a file is not
defined is a concatenation of the application name and its version, for example, for applic-
ation TestServlet with Version 1.0, it would be TestServlet-1.0.
Now, we will add the web application to the list of deployed resources by right-clicking
on the Eclipse Server tab and selecting Add and Remove . This is shown in the following
screenshot:
Search WWH ::




Custom Search