what are the jsp tags with example?



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

Post New Answer

More Core Java Interview Questions

What is the difference between a factory and abstract factory pattern?

0 Answers  


What is the difference between static class and normal class?

0 Answers  


What is the function of java?

0 Answers  


What is regex in java?

0 Answers  


wat is class level lock and object level lock

3 Answers   HCL, Persistent,






What does percent mean in java?

0 Answers  


What is the benefit of inner classes in java?

0 Answers  


What are features of java?

0 Answers  


Is integer passed by reference in java?

0 Answers  


What does the “static” keyword mean? Can you override private or static method in java?

0 Answers  


What are the types of strings?

0 Answers  


What do you mean by mnemonics?

0 Answers  


Categories