JSP Create Variable

Ads
 

JSP Create Variable

JSP Create Variable is used to create a variable in jsp

JSP Create Variable is used to create a variable in jsp

JSP Create Variable

        

JSP Create Variable is used to create a variable in jsp. The scriptlets include a java code to be written as <%! %> provided by the jsp.

Understand with Example

The Tutorial illustrate an example from 'JSP Create Variable'. To understand the example we create an array variable of string type where we have defined the days of week and it is written inside the scriptlets. The for loop inside the scriptlet execute the loop repeatedly till the integer i  become less than length of days. Finally the out.println print the days in a week.

 

 

 

Here is the code of variable.jsp

<html>
<body>
<h1>Create Variable</h1>
<%
String days[] = {"Sunday","Monday","Tuesday",
 "Wednesday","Thursday","Friday","Saturday"};
out.println("Days of week= ");
for(int i=0;i<days.length;i++){
out.println(days[i]);
}
%>
</body>
</html>

Output will be displayed as:

Download Source Code:

 

Ads

Ads