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

can u handle an error if u write Thowable in the catch class lise try { some errorneous code }catch(Throwable e){ ...}

4 Answers  


What happens to a static var that is defined within a method of a class?

0 Answers  


How to create an instance of a class without using "new" operator? Plz help me out properly.Thank u.

10 Answers   CSC,


Can we have multiple classes in a single file?

0 Answers  


What is java util concurrentmodificationexception?

0 Answers  






How do generics work?

0 Answers  


How to find the given number is a prime number or not by getting input from the user

0 Answers  


If there are two notepad opened and working on it . is this a process or thread? computer based Live Example to differentiate between Thread , Process , and Multi tasking ?

3 Answers   TCS, Wipro,


What does jenkins do?

0 Answers  


What do you mean by jjs in java8?

0 Answers  


What is void in java?

0 Answers  


What is the purpose of the enableevents() method?

0 Answers  


Categories