Setup Menus in Admin Panel

3.1 Scripting Elements

Scripting Elements

There are 3 main Scripting elements

1. Scriptlet

Scriptletwill be used to write any valid java statements like local variables or any other java code. All the statements inside Scriptletmust be terminated with semicolon. All the statements inside the scriplet will be placed inside jspService method that is executed every time the JSP is invoked

<html>
<body>
<%
// This is a scriptlet.  Notice that the "date"
//variable we declare here is available in the
// embedded expression later on.
<%int count = 0;   %>       
 Page Count is  <% out.println(++count); %>
System.out.println( "Evaluating date now" );
java.util.Date date = new java.util.Date();
%>
Hello!  The time is now <%= date %>
</body>
</html>

 

2. Expressions

Expression is a short form of out.println().Expressions  are short form of jsp.All the expressions inside the jsp are placed inside the jspService() method.

<html>
<head>
<title>Insert title here</title>
</head>
<%
int count = 0;
%>
<body>
Page Count is  <%= ++count %>
</body>
</html>

 3.Declarations 

Declarations is used to write class level members ie instance/static variables and methods.

<html>
<head>
<title>Methods Declaration</title>
</head>
<body>
<%!int sum(int num1,int num2,int num3)
{return num1+num2+num3;}  %>
<%="Result is: "+ sum(10,40,50) %>
</body>
</html>
January 16, 2016

0 responses on "3.1 Scripting Elements"

Leave a Message

Your email address will not be published. Required fields are marked *

© Pradeep Academy.  Design & Developed by