Saturday, March 14, 2009

a.jsp

Question :a.jsp
<%!
int x = 10;
%>
b.jsp
<%@ include file="a.jsp" %>
<%
int x = 20;
out.println("x:"+x);
%>
When the above programme is invoked as http://localhost:8080/b.jsp,
what is the output? (JSP)


Answer :Compiler error as x is already initialised.
When a.jsp file is included in b.jsp, all the variables of a.jsp are also
invoked
in b.jsp.

No comments: