What is JSP ?

JSP- Java Server pages is the technology which helps the user to create static and dynamic web content. Basically a file with .jsp extension.
In a sentence we can say – writing java code inside html file.

How to write java code inside html?

There are three main tag to write java code inside html.

1. Scriptlet tag to execute java code inside html.

<% String msg=”Hello world” Out.println(msg); %>

2. Declaration tag to declare global method and global variable

<%! String msg=”how are you” %>

3. Expression tag to display java variables

<%= msg %>

Follow the below step to create JSP project.

Step 1

Create a dynamic web project. If you don’t know how to create dynamic web project see my post

Step 2

Create .jsp page.

jsp project structure
jsp project structure


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"     pageEncoding="ISO-8859-1"%>Insert title here

<%!String msg="Hello World"; %>

<% out.println("From scriptlet   "+msg); %>

<%="From expression   "+msg %>


download Code
download Code

Be the first to comment

Leave a Reply

Your email address will not be published.