Home Jsp JSP Create Variable
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

JSP Create Variable

Advertisement
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:

 

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 16, 2009

Related Tutorials

Ask Questions?    Discuss: JSP Create Variable  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com