I am explaining every step to run tomcat in window and how to setup your projects and running Servlets.
1. Install JDK before installing tomcat.
a) I installed JDK1.6.0 onC:\Java\jdk1.6.0
NOTE: Do not installed JDK under C:\Program Files. I just faced problem after setting my
environment variable on Window Xp.
2. Download the latest version of tomcat.
tomcat.apache.org , i downloaded Apache Tomcat 7.0.65.I rename downloaded folder to "apache-tomcat" and placed it at E:\apache-tomcat.Go to "Start" --> "My Computer" --> Right click--> "Property"--> Click "Advance Tab" --> "Environment Variables" --> Opens a window where you have to create new Environment Variables As Written Below
1. Install JDK before installing tomcat.
a) I installed JDK1.6.0 onC:\Java\jdk1.6.0
NOTE: Do not installed JDK under C:\Program Files. I just faced problem after setting my
environment variable on Window Xp.
2. Download the latest version of tomcat.
tomcat.apache.org , i downloaded Apache Tomcat 7.0.65.I rename downloaded folder to "apache-tomcat" and placed it at E:\apache-tomcat.Go to "Start" --> "My Computer" --> Right click--> "Property"--> Click "Advance Tab" --> "Environment Variables" --> Opens a window where you have to create new Environment Variables As Written Below
3. Now We have to edit configuration files E:\apache-tomcat\conf folder
- /* Under User Variable click New */
- Variable Name CATALINA_HOME
- Variable Value E:\apache-tomcat , Press ok
- Variable Name JAVA_HOME
- Variable Value C:\Java\jdk1.6.0, Press ok
- Variable Name JAVA_HOME
- Variable Value C:\Java\jdk1.6.0, Press ok
- Variable Name PATH
- Variable Value C:\Java\jdk1.6.0\bin, Press ok
- // Under System Variable click New
- Variable Name CALSSPATH
- Variable Value C:\Java\jdk1.6.0\bin;E:\apache-tomcat\lib\servlet-api.jar, Press ok
- Open file context.xml find line/xml tag <Context>
- and replace by <Context reloadable="true">
- <servlet>...</servlet> inside this tag find
- <param-value>false</param-value>
- and replace with <param-value>true</param-value>
- Open file tomcat-users.xml and placed below code inside<tomcat-users>...</tomcat-users>
4.Restart your computer. After above steps configuration. Lets create a new project.
- <role rolename="manager-gui"/>
- <role rolename="admin-gui"/>
- <user username="boy108zon" password="boy108zon" roles="manager-gui,admin-gui"/>
1. I created a folder called store in E:\apache-tomcat\webapps\
2. Create Structure under
3. Placed below xml code in web.xml created as above
- store(Project Folder) ---> WEB-INF(DIR) --> classes(DIR) , web.xml (FILE)
- classes(DIR)-->HelloWorld.java (File)
4. Open http://localhost:8080/ You can see Tomcat Statup Page , you can click on Mange App it will ask you to enter username and password , As you putted OR placed in tomcat-users.xml.
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <servlet>
- <servlet-name>HelloWorld</servlet-name>
- <servlet-class>HelloWorld</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>HelloWorld</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- </web-app>