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

State the difference between creating string as new () and literal.

0 Answers  


Can there be an abstract class with no abstract methods in it?

1 Answers  


What is parameter example?

0 Answers  


what is collatration?

0 Answers  


explain what is transient variable in java?

0 Answers  






Which is fastest collection in java?

0 Answers  


what are the differences between java and .net?..why u choose java?

1 Answers  


What access modifiers can be used for methods?

0 Answers  


Is string passed by reference in java?

0 Answers  


When we can access the static data member without creating the object what is the need of the object in java.

5 Answers   Airhub, ssinformatics,


What are Inner classes?

4 Answers  


how tha garbage collector know that the object will be deleted? on which algorithm the garbage collector works? what is the working principle of garbage collector? How manay types of garbage collectors r there?

1 Answers   HP, SparkTG,


Categories