Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting up a servlet

Status
Not open for further replies.

jlipsitz

Programmer
Jul 13, 2003
14
US
Hi

I am new to tomcat and trying to setup a servlet to run on tomcat in linux. I have already created a .war file, but I am not sure where to place it. I thought there would be a folder in WEB-APPS to place the .war file and the class files. Also what changes need to be made if any to web.xml and server.xml?

Thanks
 

So, taking for granted that you have organised you webapp in the correct structure - ie classes live under "contextRoot/WEB-INF/classes", then all you do is go to your contextRoot and type "jar -cvf mywar.war *" and then dump this file in TOMCAT_HOME/webapps. No changes should be required to server.xml or the conf/web.xml file. Depending on whether you have the "invoker" servlet active (see conf/web.xml) you may or may not need to map your servlet in your contextRoot/WEB-INF/web.xml file like so :

Code:
    <servlet>
        <servlet-name>YourServlet</servlet-name>
        <servlet-class>
          YourServlet
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>YourServlet</servlet-name>
        <url-pattern>/servlet/YourServlet</url-pattern>
    </servlet-mapping>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top