Pages

Wednesday, July 14, 2010

Create a Web Application Context [JBoss EWS – TOMCAT]

Share it Please

It is generally a good practice to keep your web applications within a different directory rather that Root folder .This prevents unwanted users to access Root Server and get critical information.

When we place our web application in a different directory, we need to create a context for accessing the web application. Here are the steps that allow deploying an application to a different directory and setting a context for accessing the application.

Creating a sample Web application – we will create a sample web application which displays the name of the servlet and the method of accessing.

Creating a xml file –
Go to conf -> Catalina -> local host,
Create an xml file with name test.xml.
Copy the contents to the test.xml file,

<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="${catalina.home}/webapps/test" privileged="true"
         antiResourceLocking="false" antiJARLocking="false" path="/test"/>
                  

So let’s take a look at the parts,
Context – a context is a single web application with in a Tomcat instance.
docBase – path to your web application directory or a war file.
Path - The URI path relative to the root of the web server (”/“) where this webapp should be mapped
Privileged – if we set this to true, we are allowing this web application to have access to Tomcat internal objects and classes.

So not the directory structure for test application in webapps look’s like ,


             

We have the index.jsp file in the WEB-INF.

So now restart the server to see that you can access your web application by using,

In this way we can change the context path for an application.

More intersting things to come , So Happy Coding.....

No comments :

Post a Comment