what are the jsp tags with example?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the types of literals?

566


How do you compare values in java?

549


What is udp in java?

534


What is java argument list?

522


When can you say a graph to be a tree?

637






When is the finalize() called?

701


Is java still necessary?

621


What does it mean that a class or member is final?

559


What is array and arraylist in java?

533


What are the different types of multitasking?

660


What are the advantages of encapsulation in java?

553


What do you mean by hashing?

645


What is constructor and its types?

541


Which types of exceptions are caught at compile time?

566


What is numeric data type?

529