IT Placement Papers JAVA JSP
This category contains JSP Interview Questions and Answers |
|
JSP Decleratives are the JSP tag used to declare variables. Declaratives
are enclosed in the <%! %> tag and ends in semi-colon. You declare variables and
functions in the declaration tag and can use anywhere in the JSP. Here is the
example of declaratives:
<%@page contentType="text/html" %>
<%!
int cnt=0;
private int getCount(){
//increment cnt and return the value
cnt++;
return cnt;
}
%>
Values of Cnt are:
<%=getCount()%>
13. Question: What is JSP Scriptlet?
Answer: JSP Scriptlet is jsp tag which is used to enclose java code in the JSP
pages. Scriptlets begins with <% tag and ends with %> tag. Java code written
inside scriptlet executes every time the JSP is invoked.
Example:
<%
//java codes
String userName=null;
userName=request.getParameter("userName");
%>
Only registered users can write comments. Please login or register.
|