• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock exam doubts

 
deepti bellubbi
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Following are the mock exam questions from javaprepare. Please clarify what the answers should be.

Q1.
Choose the correct from the following
1. HttpSessionListener2. HttpSessionBindingListener
3. HttpSessionActivationListener4. None of these

session is activated or passivated
session is timed out
an attribute is replaced in the session
a session is created

I think the answer should be 3,2,4,1 respectively. But the answers provided were different.
_______________________________________________________________________
Q2.You are working with a tag library which is packaged in a jar file named htmlutil.jar. This jar file also contains a META-INF/htmlutil.tld file which has a uri element as follows:
<uri>http://www.xyzcorp.com/htmlLib</uri>
What can you do to access this library from your JSP pages?

Select 1 correct option.

1.You must define the <taglib> element in the web.xml to specify the mapping for <taglib-uri> to the location of this jar file.
2.There is no need for the <taglib> element in the web.xml, however, you need the taglib directive in the JSP pages.
3.You can directly access the tags of this library from the JSP pages without any taglib directive.
4.You do not need the taglib directive, but you do need to specify the <taglib> element in the web.xml.
5.None of these.

The answer given is "2".

Please provide your suggestions.

Thanks
--Deepti
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A1= 3,1,4,1

HttpSessionListener (1) is directly associated with a session timeout since it results in a call to its sessionDestroyed method.

HttpSessionBindingListener (2) is associated with the binding and unbinding of attributes from a session. Therefore, HttpSessionBindingListener is indirectly associated with a session timeout since its valueUnbound method is called before the session is destroyed.

A2:
1 is incorrect because the tld is in the standard location that the container will search when building its uri - tld map.

2 is correct because of (1) and because the tag is not a standard tag/action (which requires no taglib dir).

3 is incorrect because the tag is not a standard tag/action (which requires no taglib dir).

4 is incorrect because 1 and 3 are incorrect.

5 is incorrect because 2 is correct.
 
deepti bellubbi
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. However for Q1 I still have a doubt

In the specs we have:
HttpSessionBindingListener:
"Causes an object to be notified when it is bound to or unbound from a session.
The object is notified by an HttpSessionBindingEvent object. This may be as a
result of a servlet programmer explicitly unbinding an attribute from a session,due to a session being invalidated, or due to a session timing out."

Then why is my answer wrong.
 
Dee Brown
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since both HttpSessionBindingListener and HttpSessionListener are possible answers, for your answer to be correct would be to say that the callback to the HttpSessionBindingListener is more closely associated with a session timeout than the callback to the HttpSessionListener, which is not true. The callback to the HttpSessionBindingListener occurs when an attribute is unbound, which can occur as a result of a session timeout.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic