• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Toughest Questions for Oracle JSP Servlet (SCWCD 5.0) Doubts

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

http://www.enthuware.com/forum/viewtopic.php?f=31&t=13




Following are some of the questions from Enthuware.
I have posted all the questions in a single post as I thought that would be a better than posting them in different posts.
Its my request to the fellow ranchers to help me in the following questions.

---------------------------------------------------------------------------------------------------------------------------------------------------
Q. No. 2
Which of the following are valid JSP code fragments?

Each option shows code for an independent JSP file.



(a) <%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>
(b) <%Date d = new Date();
out.println(d);
%>
(c) <%= String val = request.getParameter("hello");
out.println(val);
%>
(d) <%!
Hashtable ht = new Hashtable();
{
ht.put("max", "10");
}
%>
(e) <%!
Hashtable ht = new Hashtable();
ht.put("max", "10");
%>

ANSWER:B,D

I think answer should be A,B,D as the autoflush can have true as value.


--------------------------------------------------------------------------------
Q. No. 5


Identify the authentication techniques that are based on builtin mechanisms of HTTP.



(a) HTTP does not have any built in mechanism for authentication.
(b) BASIC
(c) CLIENT-CERT
(d) DIGEST
(e) FORM

B,d-correct answer
I unable to get the answer.please Help.


---------------------------------------------------------------------------------------
Q3.
Which of the following statements is correct regarding a RequestDispatcher object?



(a) A call to forward() clears the output buffer before the target resource is invoked.
(b) A call to include() clears the output buffer before the target resource is invoked.
(c) The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.
(d) It is not advisable for the forwarding resource to produce any output.
(e) Both, forward() and include(), allow the caller resource to generate any amount of output.


Correct answer=a,c,d
I think answer should be a,d
If a.jsp has called forward to b.jsp then the calle i.e. b.jsp would have the control instead of a.jsp.So, the option c is incorrect


-------------------------------------------------------------------------------------------------------------------------------------------------

Q. No. 4


Consider the code for a jsp page :






Assuming that the servlet context of the web application DOES NOT have any attribute by the name of "key",

what will the above jsp page print when requested?



(a) It will not compile because the getAttribute() returns an Object which must be cast to String before assigning to thevalue.
(b) It will print "null".
(c) It will throw a NullPointerException.
(d) It will print "" (empty string).
(e) None of these.

Correct answer: e
The correct answer is e as there will be a compilation error application cannot be resolved.
Am i correct ?

------------------------------------------------------------------------------------------------------------------------------------------
Q. No. 18


Which of the following statements are correct regarding the forEach tag of JSTL?



(a) It can iterate over collections as well as maps.
(b) It can only iterate over arrays and collections.
(c) The EL code within the body of the tag may refer to the iteration variable but scripting code cannot.
(d) It can iterate over a Map but only the 'keys' can be used in the EL code within the body of the tag.
(e) The status object cannot be used while looping over integers using begin and end attributes.

Correct-a,c
I think a,b,d are correct.
EL can be used to iterate over arrays
and the following code can be done:



So c is incorrect and must not be in the answer.
b,d should be in the answers.

--------------------------------------------------------------------------------------------

Q. No. 20


Given the following JSP code:





Which of the following correctly creates an HTML select box on the page?



(a) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${city}</option>
</c:forEach>
</select>
(b) <select name="Cities">
<c:forEach items="${cities}" >
<option>${cities[i]}</option>
</c:forEach>
</select>
(c) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${cities[city]}</option>
</c:forEach>
</select>
(d) None of these will work.

Correct answer is d

The code in option 1 is correct as per my understanding .
If I am incorrect ,please provide a reason.



------------------------------------------------------------------------------------------------------------------
Q. No. 27


Which of the following statements are correct?



(a) The implicit variable 'session' can be used to store values needed by other servlets or JSPs of the same web application.
(b) The implicit variable 'request' can be used to store values needed by other servlets or jsps across multiple requests.
(c) You can use the implicit variable 'response' to set the content type of the output.
(d) The implicit variable 'out' is same as returned by response.getWriter()
(e) All JSPs have access to 'request', 'response' and 'session' variables.

Correct answer-a and c
B can be correcr answer as well.It can also used for storing values needed by other servlets or jsps across multiple requests.
I am unable to understand why is b not in the correct answer list.

 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its my request to fellow ranchers to help me as I have to give the exam in the next week.
If its required to reduce the number of questions on the post,i may do the same and create new post for the rest.
Please advise.Understanding these problems will help me in the preparation for SCWCD 5.
 
Ranch Hand
Posts: 55
jQuery Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answers
1)You can't have two contradicting autoflush values in same page..
so (A) is wrong.
2)the question means for which of the authentication techniques you don't have to do anything extra.
For CLIENT_CERT you need certificates and for FORM based authentication you need some extra pages.For rest of the two it is just built in HTTP.
3)answer given is right.The control returns to caller who called forward() after the resource to which it had been forwarded has done it bit.Though the caller can't write to response after the forward() call but if you use some other logic it will work.For example you can use System.out.println's to prove it.
4)yes you are correct.The implicit objects are not available under any other method except for scriptlets.
5)a and b are two contradictory statements.So only a is right.
Secondly <c:out value=”${abc.key}”/>
<c:out value=”${abc.value}
This proves d wrong.Value of a map entry can also be used inside the body of the tag.So answers are a and c only.

6)I agree with you.
7)Across multiple requests if you want to share something you cannot do the same using request object.As per request a new request object is created.So answer given is right.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankur.
What are other's view on this post.
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mohitkumar gupta wrote:


--------------------------------------------------------------------------------------------

Q. No. 20


Given the following JSP code:





Which of the following correctly creates an HTML select box on the page?



(a) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${city}</option>
</c:forEach>
</select>
(b) <select name="Cities">
<c:forEach items="${cities}" >
<option>${cities[i]}</option>
</c:forEach>
</select>
(c) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${cities[city]}</option>
</c:forEach>
</select>
(d) None of these will work.

Correct answer is d

The code in option 1 is correct as per my understanding .
If I am incorrect ,please provide a reason.



------------------------------------------------------------------------------------------------------------------


The given answer d is correct, none of these will correctly create the select box. Because List "cities" is not stored as an attribute in any of the four scopes, so EL ${cities} will not find it.
The question was "Which of the following correctly creates an HTML select box" so none of them will be correct.


For rest of the questions I agree with Ankur.

and IMO you would have got better response for your questions if you had posted them in separate posts. It might be easier for you to create a single thread but most of the readers don't have time to go through all the questions and scroll down the full page, some of them will not even read all the questions and just read one or two of top questions, also you don't get a focused discussion.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Piyush and Ankur
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic