Creating a JSP page

The JSP page and the html page are similar but the JSP page also contains java code inside it unlike an html page. A java code can be inserted in the JSP page by using the scriplet tag. The scriplet tag is started from <% and is ended with %>. We use the JSP pages for dynamic platform independent web based applications.


Example of creating JSP page in Eclipse:

To create a JSP page in eclipse you need to open the eclipse first then click on New from the file button and choose Dynamic Web Project from the drop down menu. Consider the following figure:

Dynamic Web Project

Now name your project and click on the OK button as follows:

Now name your project

On clicking the finish button your project will be created and you can see it in the project explorer:

project explorer

Now if you want to create a new JSP file you have to right click on the web content directory and from the drop down menu choose new and select JSP file:

select JSP file

Name your JSP file and click on the finish button:

finish button

Now you can write your code in the JSP file. The HTML or JSP code can be placed inside the <body> tag like we do in the HTML pages:

HTML pages

This project can be run by right clicking on project and from the drop down menu select run as then select run on server:

select run on server

A menu will be opened when you click run on server, from the menu check the button “choose an existing server” and click on the finish button:

click on the finish button

Now you can see the output in your browser:

my first jsp page