How to Convert HTML to JSP

JSP allows you to embed snippets of the Java programming language into HTML tags to create interactive content. HTML pages are static in that each time a user loads the page, the content will appear the same. JSP allows for dynamic content to be added to HTML pages, so that each time the user reloads the page, the content changes. For example, we will go through a sample where every time a user reloads the page, the date and time are changed automatically to reflect the current date and time.

Step

Open a new page in Notepad. Type the beginning and closing HTML tags with some space in between both tags. This specifies that the content will be in HTML.

Step

Step

Step

Type the opening body tag in the line below

and the closing body tag in the line directly above. Keep some empty lines between the opening and closing body tags. The rest of the lines between these two tags will specify the action the website will follow:

Step

Step

Step

Insert the following line at the top before the

tag: <%@page contentType="text/html" import="java.util.*" %>

Step

This line declares that we are importing the java.util package because we will be using the date function. Java packages consist of classes of related functions.

Step

Insert the following tag after the

tag: <%= new java.util.Date() %>. The <% and %> are JSP tags that specify an action needs to be taken with the function that is provided.

Step

Save the page with a .jsp extension.