Deployment
• Write the
servlet class.
• Compile
the Servlet class.
• web.xml
deployment descriptor file.
• Create
the war (web application archive) file.
• Deploy
and run the sample web application in tomcat web container.
Define
servlet in deployment descriptor (web.xml) :
A servlet must be defined into web.xml deployment
descriptor. Copy the following code into web.xml file and save it under WEB-INF
directory.
<?xml
version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE
web-app
PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<servlet>
<servlet-name>
welcomeServlet </servlet-name>
<servlet-class>
jsptube.tutorials.servletexample.WelcomeServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
welcomeServlet </servlet-name>
<url-pattern>
welcomeServlet </url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/ welcomeServlet
</welcome-file> </welcome-file-list>
</web-app>
Deploy
form processing servlet application to tomcat server
• You just
need to create war file of our web application and copy it to webapp directory
under your tomcat installation to deploy application to tomcat. Open command
prompt and go to root directory of our application (welcomeServlet). Create a
war file using following command.
jar -cvf
welcomeservlet.war *
• It will
create formexample.war file under FormExample directory. Copy the war file to
webapp directory under tomcat installation.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.