Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Creating a Local Variable in JSP 
 

In jsp when we have to create a method or variable we usually declare it inside the declaration tag. If we declare it inside the declaration directive then then the scope of the variables will be applicable in the whole page. This works like a instance va

 

Creating a Local Variable in JSP

                        

In jsp when we have to create a method or variable we usually declare it inside the declaration tag. If we declare it inside the declaration directive then then the scope of the variables will be applicable in the whole page. This works like a instance variable. 

Now consider a situation where we have to declare a variable as local, then we should declare the methods and variables in tag except the declaration directive. In this example we are declaring a variable in the scriptlet directive, so the scope of the variable remains upto the scriptlet directive itself. To print the variable on the browse we will use the out implicit object. 

 

 

<HTML>
  <HEAD>
    <TITLE>Creating a Variable in Jsp</TITLE>
  </HEAD>
  <BODY>
  
    <H1>Creating a Variable in jsp</H1>
    <%
	 int weeks;
	 weeks = 7;
	 out.println("Days of the weeks = " + weeks);
	 %>
	 <br>
	 <%
	 int months;
	 months = 12;
	 out.println("Number of months = "+ months);
	 %>
  </BODY>
</HTML>

Output of the Program:

 

                        

» View all related tutorials
Related Tags: c math ide data div vi value number ddl id set element elements average mount to e ics in cs

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.