10
RUNNING JAVA SERVLET PROGRAM USING APACHE TOMCAT SERVER- A LAYMAN APPROACH -J.SHIVALKAR STEP 1: Install Tomcat7 STEP 2: Create a java servlet program process.java STEP 3: Save this process.java in any folder in any drive as you wish.

Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

Embed Size (px)

DESCRIPTION

RUNNING JAVA SERVLET PROGRAM USING APACHE TOMCAT SERVERHow to run a java servlet program

Citation preview

Page 1: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

RUNNING JAVA SERVLET PROGRAM USING APACHE TOMCAT SERVER- A LAYMAN APPROACH

-J.SHIVALKAR

STEP 1: Install Tomcat7

STEP 2: Create a java servlet program process.java

STEP 3: Save this process.java in any folder in any drive as you wish.

For eg I have chosen F drive and folder named myjava

Page 2: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

Save that file “process.java” in that folder myjava

STEP 4: Open command prompt

Type F:

Then type cd myjava

Set path for java by copying the address location of bin folder under jdk.

Page 3: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

STEP 5:

Compile the process.java,this step is very important

Syntax: javac –classpath “servlet-api.jar address location” filename.java

*Note: Be careful in leaving spaces as shown above otherwise the program wouldn’t get compiled

process.class file will automatically be generated after successful compilation of the program

Page 4: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

STEP 6:

Go to Tomcat Installation Directory

STEP 7:

Go to webapps folder

STEP 8:

Double click that folder and create a folder named “sample” inside that.

STEP 9:

Create a folder named “WEB-INF” inside sample

STEP 10:

Create a file named web.xml by typing the coding in notepad and save the file as web.xml into the folder “WEB-INF” folder.

Page 5: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

STEP 11:

Create three folders inside WEB-INF namely

1. classes

2. lib

3. src

As you can see the screenshot that I have created three folders in the “WEB-INF” folder.

Page 6: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach
Page 7: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

Copy the process.class file under myjava folder and paste it into the classes folder that we have created.

Page 8: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

Copy the servlet-api file as shown in the screenshot above into the lib folder we have created

An overview of what things each folder contains

Page 9: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

STEP 12:

This is the final step

Open any browser Mozilla Firefox or Internet Explorer or Chrome or Opera

Type the URL

Syntax for the URL is

http://localhost:8080/sample/ javaprogramfilename

According to my example the URL is

http://localhost:8080/sample/process

Page 10: Running Java Servlet Program Using Apache Tomcat Server- A Layman Approach

OUTPUT: