Lecture 44
Lecture 44
Lecture 44
(KCS-602)
Unit 5
Scripting, Standard Actions
Prepared By
Sachin Kumar Sonker
Assistant Professor,UCER Naini,Allahabad
Index
• JSP Scriptlet tag
• JSP Implicit object
JSP Scriptlet tag (Scripting elements)
index.jsp
<html>
<body>
Current Time:
<%= java.util.Calendar.getInstance().getTime() %>
</body>
</html>
JSP Declaration Tag
The JSP declaration tag is used to declare fields
and methods.
The code written inside the jsp declaration tag is
placed outside the service() method of auto
generated servlet.
So it doesn't get memory at each request.
Syntax of JSP declaration tag
The syntax of the declaration tag is as follows:
<%! field or method declaration %>
Example of JSP declaration tag that declares field
index.jsp
<html>
<body>
<%! int data=50; %>
<%= "Value of the variable is:"+data %>
</body>
</html>
Example of JSP declaration tag that declares method
index.jsp
<html>
<body>
<%!
int cube(int n){
return n*n*n*;
}
%>
<%= "Cube of 3 is:"+cube(3) %>
</body>
</html>
AKTU SEMESTER QUESTION
• Discuss JSP in Detail. [2019-20]
• Write a program in jsp to fetch the
details of user from html page using
tomcat server.