what are the jsp tags with example?
Answer / sivasubramanian.k
(1)A declaration tag places a variable definition inside
the body of the java servlet class. Static data members may
be defined as well. Also inner classes should be defined
here.
Example:<%! int serverInstanceVariable = 1; %>
Declaration tags also allow methods to be defined.
<%!
/**
* Converts the Object into a string or if
* the Object is null, it returns the empty string.
*/
public String toStringOrBlank( Object obj ){
if(obj != null){
return obj.toString();
}
return "";
}
%>
(2)A scriptlet tag places the contained statements inside
the _jspService() method of the java servlet class.
<% int localStackBasedVariable = 1;
out.println(localStackBasedVariable); %>
(3)An expression tag places an expression to be evaluated
inside the java servlet class. Expressions should not be
terminated with a semi-colon .
<%= "expanded inline data " + 1 %>
(4)Also we can use the following tag to give comments in
jsp:
<%-- give your comments here --%>
| Is This Answer Correct ? | 5 Yes | 0 No |
How are variables stored in memory?
Is set ordered in java?
what is function overloading in java?
0 Answers Tavant Technologies, TCS, Virtusa,
what is the difference between ArrayList and Vector
19 Answers KPIT, Sasken, Satyam, Span Infotech, Wipro,
Which is the class in java?
What are user defined exceptions?
What does g mean in regex?
Package1 and Package2 both have a method name lets say "methodA" with different implementation. When I import both the packages in a java class how can I use both the methods?
What is the this keyword?
What does localhost mean?
What are the features of junit?
What is the method to declare member of a class static?