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 |
Howmany address lines are required to addressing 1 MB memory?
8 Answers Beatroot Technologies, CSC, HCL, Hexaware, IBM,
Can we place the any object to key attribute of HashMap<key,value>?
what is abstract method with example?
Does java initialize arrays to zero?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? Or extending thread class or implementing runnable interface. Which is better? : Java thread
What is java util hashmap?
Can an abstract class have a constructor?
If an object reference is set to null, will the garbage collector immediately free the memory held by that object?
What is the major advantage of external iteration over internal iteration?
Which collection does not allow duplicates in java?
What are the types of loops in Java, and how are they used?
Why are variables important in research?