• Post Reply Bookmark Topic Watch Topic
  • New Topic

Mock Exam Doubts

 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given an HttpServletRequest request and an HttpServletResponse response:
1 HttpSession session = null;
2 // insert code here
3 if(session == null) {
4 // do something if session does not exist
5 } else {
6 // do something if session exists
7 }
To implement the design intent, which statement must be inserted at line 42?
A. session = response.getSessionj();
B. session = requset.getSessionj();
C. session = response.getSessionj(true);
D. session = response.getSessionj(false);
E. session = response.getSessionj("jsessionid"););
Answer: D

I Think it should be
request .getSessionj(false);

2.
Given in a single JSP page:
<%@ taglib prefix='java' uri='myTags' %>
<%@ taglib prefix='JAVA' uri='moreTags' %>
Which two are true? (Choose two.)
A. The prefix 'java' is reserved.
B. The URI 'myTags' must be properly mapped to a TLD file by the web container.
C. A translation error occurs because the prefix is considered identical by the web container.
D. For the tag usage <jave:tag1/>, the tag1 must be unique in the union of tag names in 'myTags' and
'moreTags'.
Answer: A, B

Please clarify
 
Harvinder Thakur
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 1) yes , it should be request.getSession(false); assuming it is line 2 and not 42

Question 2) D is wrong as prefixes act as namespaces or package names as in java classes.
C is wrong as i guess prefixes are case sensitive. Please verify...
 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Yes even i feel B is the wrong answer.
 
Harvinder Thakur
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry B was a typo...... actually i've modified my previous message to change from B to C.

B is correct as you have to specfiy the <uri>myTags</uri> element in the .tld file. This uri then maps to the uri attribute of the taglib directive
 
Harvinder Thakur
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also it is generally nice to mention the source of your mock exam questions
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!