Time remaining
:
:
Test Status
JSPTEST1
Ques 1 :
Given that www.example.com/SCWCDtestApp is a validly deployed Java EE web application and that all of the JSP files specified in the requests below exist in the locations specified.Which two requests, issued from a browser, will return an HTTP 404 error?
(A) http://www.example.com/SCWCDtestApp/test.jsp
(B) http://www.example.com/SCWCDtestApp/Customer/test.jsp
(C) http://www.example.com/SCWCDtestApp/WEB-INF/test.jsp
(D) http://www.example.com/SCWCDtestApp/Customer/Update/test.jsp
Ques 2 :
What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()?
(A) The two methods perform identically.
(B) forward executes on the client while sendRedirect() executes on the server.
(C) forward executes on the server while sendRedirect() executes on the client.
Ques 3 :
What is the effect of executing the following JSP statement, assuming a class with name Employee exists in classes package.
<%@ page import = "classes.Employee" %> <jsp:useBean id="employee" class="classes.Employee" scope="session"/> <jsp:setProperty name="employee" property="*"/>
(A) The code does not compile as property attribute cannot take * as a value.
(B) The code sets value of all properties of employee bean to "*".
(C) The code sets the values of all properties of employee bean to matrching parameters in request object.
(D) The code does not compile as there is no property attribute of setProperty tag.
Ques 4 :
How many numbers are printed, when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
${item}
(A) 1
(B) 5
(C) 6
(D) 11
Ques 5 :
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:if test="${var==1}" var="result" scope="session">
<c:out value="${result}"/>
</c:if>
(A) true
(B) The JSTL code does not compile as attribute for if tag are not correct.
(C) false
(D) Nothing gets printed.
Ques 6 :
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:forEach var="item" begin="0" end="0" step="2">
<c:out value="${item}" default="abc"/>
</c:forEach>
The JSTL code does not compile as an attribute for forEach tag is not correct.
(A) 0
(B) ABC
(C) 2
(D) Nothing gets printed as c.out statement does not get executed.
Ques 7 :
Which of the following is legal JSP syntax to print the value of i. Select the one correct answer
(A) <%= i; %>
(B) <%int i = 1;%>
(C) <%int i = 1; i; %>
(D) <%int i = 1%>
Ques 8 :
Why beans are used in J2EE architecture in stead of writing all the code in JSPs?
(A) Allows separation of roles between web developers and application developers
(B) Allows integration with Content Management tools
Ques 9 :
Why DB connections are not written directly in JSPs ?
(A) Not a standard J2EE architecture
(B) Load Balancing is not possible
(C) All the above
(D) Both (b) and (c)
Ques 10 :
In JSP, how can you know what HTTP method (GET or POST) is used by client request ?
(A) by using request.setMethod()
(B) impossible to know
(C) by using request.getMethod()
Ques 11 :
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp?name="John". The test.jsp contains the following code.
1 <%! String myName=request.getParameter();%>
2 <% String test= "welcome" + myName; %>
3 <%= test%>
(A) The program prints "Welcome John"
(B) The program gives a syntax error because of the statement 1
(C) The program gives a syntax error because of the statement 2
(D) The program gives a syntax error because of the statement 3
Ques 12 :
Which of the following correctly represents the following JSP statement. Select the one correct answer.
(A) < jsp:statement >x< /jsp:statement >
(B) < jsp:declaration >x< /jsp:declaration >
(C) < jsp:scriptlet >x< /jsp:scriptlet >
(D) < jsp:expression >x< /jsp:expression >
Ques 13 :
Which of the following correctly represents the following JSP statement. Select the one correct answer.
(A) < jsp:expression >x=1;< /jsp:expression >
(B) < jsp:statement >x=1;< /jsp:statement >
(C) < jsp:declaration >x=1;< /jsp:declaration >
(D) < jsp:scriptlet >x=1;< /jsp:scriptlet >
Ques 14 :
How many numbers gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:choose>
<c:when test="${item>0}">
<c:out value="1"/>
</c:when>
<c:when test="${item==2}">
<c:out value="2"/>
</c:when>
<c:when test="${item<2}">
<c:out value="3"/>
</c:when>
<c:otherwise>
<c:out value="4"/>
</c:otherwise>
</c:choose>
(A) One number gets printed.
(B) Two numbers gets printed.
(C) Three numbers gets printed.
(D) Four numbers gets printed.
Ques 15 :
Which numbers gets printed when the following JSTL code fragment is executed? Select the correct answers.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="j" value="4,3,2,1"/>
<c:forEach items="${j}" var="item" begin="1" end="2">
<c:out value="${item}" default="abc"/>
</c:forEach>
(A) 1
(B) 4
(C) 2
(D) abc
Ques 16 :
Which of these represent the correct path for the core JSTL library in JSTL version 1.1? Select the one correct answer.
(A) http://java.sun.com/jsp/jstl/core
(B) http://java.sun.com/jsp/core
(C) http://java.sun.com/core
(D) http://java.sun.com/jsp/jstl1.1/core
Ques 17 :
What gets printed when the following JSP code is invoked in a browser. Select the one correct answer.
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>
(A) The browser will print either hello or hi based upon the return value of random.
(B) The string hello will always get printed.
(C) The string hi will always get printed.
(D) The JSP file will not compile.
Ques 18 :
Which of the following are correct. Select the one correct answer.
(A) JSP scriptlets and declarations result in code that is inserted inside the _jspService method.
(B) The JSP statement <%! int x; %> is equivalent to the statement
int x;
.
(C) The following are some of the predefined variables that maybe used in JSP expression - httpSession, context.
(D) To use the character %> inside a scriptlet, you may use %\> instead.
Ques 19 :
What gets printed when the following is compiled. Select the one correct answer.
<% int y = 0; %>
<% int z = 0; %>
<% for(int x=0;x<3;x++) { %>
<% z++;++y;%>
<% }%>
<% if(z<y) {%>
<%= z%>
<% } else {%>
<%= z - 1%>
<% }%>
(A) 1
(B) 2
(C) 3
(D) The program generates compilation error.
Ques 20 :
Which of the following JSP variables are not available within a JSP expression. Select the one correct answer.
(A) out
(B) httpsession
(C) session
(D) request
Submit Answer
Don't Refresh the Page !! ...