आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
JSP - Declaration Tag

JSP Declaration

JSP के declaration tag में variables, methods और classes को declare किया जाता है | अगर किसी भी variable, methhod या class को इस्तेमाल करने से पहले उसे declare किया जाता है |

Syntax for JSP Declaration :

<% declaration %>
OR
<jsp:declaration>
declaration
</jsp:declaration>

Example For Variable Declaration

Source Code :
<html>
<head>
<title>Declaration Tag - Variable Declaration</title>
</head>
<body>

<%! int a = 1; %>
<jsp:declaration>
int b = 2;
</jsp:declaration>

<% 
out.print("Value of a : " + a + "<br />"); 
out.print("Value of b : " + b);
%>

</body>
</html>
Output :
Value of a : 1
Value of b : 2


Example for Method Declaration

Source Code :
<html>
<head>
<title>Declaration Tag - Method Declaration</title>
</head>
<body>

<%! 
String ConcatStr(String str1, String str2){
	return str1 + str2;
}
%>
<% out.print(ConcatStr("Hello", " World")); %>

</body>
</html>
Output :
Hello World


Example for Class Declaration

Source Code :
<html>
<head>
<title>Declaration Tag - Class Declaration</title>
</head>
<body>

<%! 
public class MyClass{
	public String myMethod(){
		return "Hello World";
	}
}
%>
<% 
MyClass c = new MyClass();
out.print(c.myMethod());
%>

</body>
</html>
Output :
Hello World