JSP scripting element
JSP provide
1.Scriptlet tag
2.Expression tag
2.Declaration tag
Scriptlet tag
In Scriptlet tag you can write java program.
syntax:
1 2 3 4 5 | <% //java Program %> |
Let’s understand scriptlet tag using this simple JSP program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.util.Date" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <h1>This is a JSP page</h1> <% //Here you can write java code... System.out.print("hi This is bhavesh lakhani"); //displaying current date using java.util.Date out.println(new Date()); %> </body> </html> |
Accessing JSP from Browser
Console output: