Pr.Pg Next Pg

Scripting Element Programs in jsp tutorials

 

Program to show how to use directory scripting

Sam Sir

<%-- Program name index001.jsp --%>

<%-- Program to show how to use directory scripting --%>

 

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@page import="java.util.Date;" %>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h4>This is Simple Demo to show how to import any Java package in JSP</h4>

<%=new Date()%>

</body>

</html>

Output

directory scripting elements

 


 

Program to show how to use different scripting element.

Sam Sir

<%-- Program name index002.jsp --%>

<%-- Program to show how to use different scripting element. --%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<html>

<head>

<title>JSP Scripting</title>

</head>

<body>

<%-- declaration tag --%>

<%! int i = 10; %>

 

<%-- scriptlet tag --%>

<% out.print("i = "+i); %>

<br>

<br>

<% out.print("for loop execution start"); %>

<br>

<%

for(int j=1;j<=10;j++)

{

out.print("j = "+j);

%>

<br>

<%

}

out.print("for loop execution complete");

%>

<br>

<br>

 

<%-- expression tag --%>

<%! int a = 10;

int b = 40;

%>

The addition of two variable : a + b = 10 + 40 = <%= a+b %>

<br>

<br>

</body>

</html>

Output

scriptlet elements

Pr.Pg border                                              Next Pg