Hi,
I am trying to answer your queries.
1)
test.jsp
===============
<% String str="hello"; %>
<%= str %>
<jsp:include page="another.jsp" flush="true" />
<% str+=" World";
out.println(str);
%>
another.jsp
===========
<% String str="hi";
out.println(str); %>
What is the output for the test.jsp file?
The answer should be "hi hello World" If the writer is buffered, Otherwise it will "hello hi hello World", as if the out is not buffered it will not flushed
==========================================================================
2) Select the EL fragment which will produce compilation erro? select two choices
a) ${1+'1'}
b) ${varDoesntExist+1}
c) ${sessionScope * 2}
d) ${2/varDoesntExist}
e) ${2/ varContainingZero }
f) ${varDoesntExist1 <varDoesntExist2}
g) ${!true - !false}
======================================================================
My Answers are C and G
The outpu of other options are
a) 2 b) 1 d) Infinity e) Infinity f) false
3) Acme Inc decides to develop a Swing application to acces the central office data from branches all
over the world. The central office would enter business data using this application and the
branches would mostly read these data over the networl. te application would use EJB for
accessing the enterprise data. one of the primary goal of the application is to provide faster
response time both at central and branch office.
The other goal is to reduce the application dev time by devloping the business and UI Compenents
in parallel without waiting for each other.
Given this scneario which of the following j2EE design would solve the problem effectively?
select two choices.
a) Intercepting Filter
b) MVC
c) Front controller
d) Servive Locator
e) Business delegate
f) Value object
I go for B and E
==========================================================================
4) PostTest.html
===============
<html>
<body>
<form method="POST" action="/servlet/PostTest">
val1=<input type="text" name="value1"><br>
val2=<input type="text" name="value2"><br>
<input type="submit" name="AddButton">
</form>
</body>
</html>
PostTest.java
==============
public void doPost(HttpServletRequest req,HttpServletResponse res){
BufferedReader inReader=req.getReader();
PrintWriter out=res.getWriter();
String val1Str=inReader.readLine();
String val2Str=inReader.readLine();
out.println("Value obtained manually =" val1Str);
out.println("Value obtained manually =" val2Str);
out.println("Value obtained again is =" req.getParameter("Value1"));
out.println("Value obtained again is =" req.getParameter("Value2"));
}
The values entered are value1=500 and value2=600. what is the o/p?
a) compilation error
b) value obationed manually = null
value obationed manually = null
value obationed again is = 500
value obationed again is = 600
c) value obationed manually =
value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = 500
value obationed again is = 600
d) value obationed manually =
value1=500 &&value2=600&&AddButton=Submit+Query
value obatained again manually is = null
value obationed again is = null
value obationed again is = null
My answer is A. The doPost must throws the IOException and Servlet Exception or hanldle internally.
If the methods signature is properly defined The answer will be D
==========================================================================
5) what is the o/p?
<% sesson.setAttribute("varCents","20");
%>
$100.${varCents}
1) compliation error
2) classcastException
3) prints $100.20
4) prints $100.$20
===============================================================
Here is typo in session speling , otherwise the output is 3
6) can a userdefined identifier be named sessionScope in a jsp file?
Yes, as long as it is not used in EL
Hope it help
Thanks