1.
Install tomcat server on your pc / laptop.
2.
Start eclipse and create new project like, File
Menu -> New -> dynamic web project -> write project name. Suppose
project name is “First_Pro”
3.
After entering name of project click on next
button, again click on next button, click on check box “generate web.xml
deployment descriptor”
then click on finish
button.
4.
Now right click on your project name click on
new and select jsp file
5.
After clicking on “Jsp File” as like above
image.At the time creation of jsp file make sure your file is place in
webcontent folder as shown picture.Name your first index file as index.jsp. and
click on finish button
6.
After clicking on finish button your index.jsp file
is look like this.
7.
Now edit the readymade code like this
<%@ page language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>First Pro<title>
</head>
<body>
<h1>Its my First JSP program</h1>
</body>
</html>
8.
Save the code
file->save OR ctrl+s
9.
To load libraries right
click on your project -> build path -> configure build path
After clicking on configure build path,
java build path dialog box is shown. In libraries tab -> click on “Add
external jars”
In jar selection dialog box go to your “c:\program
files\tomcat\lib” and select servelet-api.jar and tomcat-api.jar. The
servlet-api.jar need for run servlet programs and tomcat-api.jar need for
connect with tomcat. After selecting files click on open button.
After selecting jar files they will appear
in your java build path as shown in image after that click on deployment
assembly as marked in image
After clicking on deployment assembly click
on apply button.
In web deployment assembly click on add
button.
After clicking on add button, new assembly
directive dialog box will appear. In that click on java build path entities and
click on next button.
After clicking on next button, you will see
servlet-api.jar and and tomcat-api.jar. select both files and click on finish
button.
After in “Edit Variable User” click on new
button enter “Variable Name” as “path” and “Variable value” as your jdk bin
path and its end use ;.; and click on Ok button again Ok button again Ok
button.
11.
Now to the run the
program right click on your project -> run as -> run on server
12.
After clicking on “Run on Server” select your
tomcat server version. After then click on next button.
If in the configure box there are more than
one project are available then click on remove all. And click on finish button.
No comments:
Post a Comment