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

Write a program to print the pattern given below

0 Answers  


Why Java is called as purely platform independent..? Explain briefly..dont Give regular answers Explain with your own example..?

8 Answers   Nokia,


2) Suppose there are 5 directories having lot of files (say txt files) in each directory. 2 things :- 2.1) You want to search for filenames which have a particular pattern. 2.2) Out of these filtered files you want to search for a particular keyword or a search string. How can you achieve this?

0 Answers   RBS, TCS,


How do you empty a list in java?

0 Answers  


posted in online test

1 Answers  






What is java in detail?

0 Answers  


Java run-time system generates What class of exceptions?

2 Answers   TCS,


What is string english?

0 Answers  


When super keyword is used?

0 Answers  


What is the difference between method and means?

0 Answers  


Is null an object in java?

0 Answers  


What is a variable analysis?

0 Answers  


Categories