You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$10
For Premium members:
JSP scripting tags are very important tags which allow a java programmer to add a script code into the java code of a JSP.
Working with Scripting Tags :
JSP Scripting Tags allow a java programmer to add a script code into the java code of a JSP. In most of the cases java is the scripting language used to build a JSP page. There are many types of scripting tag:
Types of Scripting Tags:
There are mainly three JSP scripting tags:
Example:
<html><body><%for (int i=0; i<10;i++){out.println(i);}%></body></html>
The Declarative Tag: This tag allows you to declare instance and class variable and implement class methods such as jspInit and jspDestroy. JSP declaration is used to declare variables and methods in a page's scripting language.
The syntax for a declaration is as follows:<%! script code%>
<%!int i, j;int fun (int i){return i;}%><%i=1;><%j=fun (i);%><%out.println(j);%>
The Expression Tag: Through this tag we show the resultant value. The expression tag places in the out. print method during the translation stage of the JSP lifecycle.
A JSP expression is used to insert the value of a scripting language expression, converted into a string, into the data stream returned to the client. When the scripting language is the Java programming language, an expression is transformed into a statement that converts the value of the expression into a String object and inserts it into the implicit out object.
The syntax for an expression is as follows:
<%= script code%>
<%! int count; %><html> <body><% count++ %>This page is requested by <%=count%> number of users till now.</body></html>
Example of Scripting tags:
<%@page import="java.util.*" language="java" %> <html> <body bgcolor="pink"> <center><h1>Using Scripting Elements</h1></center> <%! int count,a,b; int fun (int a) { return 10*a; }%> <% a=1; count++; for (int i=0;i<5;i++) { out.println("value of i in iteration no.<br/>"); } b=fun(a); out.println("value of b"); %> This page is requested by <b><%=count%></b>number of times on date <b><%=new Date()%> </b> </body> </html>
Running the application on the server: Run the tomcat server then write the below line in the URL http://localhost:8080/JSP/ Here JSP is the Context path, which we mentioned in the server.xml file, which is present in (E:\Program Files\Apache Software Foundation\Tomcat 6.0\conf) directory. After giving the URL a set a listing will come, here only one appears As index.JSP,click it http://localhost:8080/JSP/index.JSP
OUTPUT:
Pro WPF: Windows Presentation Foundation in .NET 3.0