Poonam Agarwal wrote:Which of the following statements is correct?
1. GenericServlet defines but does not implement doHead() method.
2. The default implementation of HttpServlet class's doHead() method calls the doGet() method.
3. The HttpServlet class does not implement a dummy doHead() method.
4. There is no special method for HEAD request, doGet() handles HEAD requests.
5. If the servlet does not implement doHead(), doGet() will be called upon HTTP HEAD request.
The above question is from Enthuware mock and the mentioned right option is 2.
Can anybody elaborate it more OR suggest something to verify for the same.
Thanks
Adrian Muscalu wrote:sessionMap is not safe because objects stored into the session are not thread safe. You are not creating a new object sessionMap, you are just pointing to an existing object which is not thread safe.
theMap is not safe because multiple threads can access your servlet in the same time. If one instance modifies theMap then all other instances will be having the new changes. There are different ways to avoid this.
Regards,
Adrian
[ November 08, 2002: Message edited by: Adrian Muscalu ]
public void doPost(HttpServletRequest req, HttpServletResponse res)
{
HashMap sessionMap = (HashMap) req.getSession().getAttribute("map");
//do something
}
Arun Giridharan wrote:well! i failed in all the Mock exam i took about 5 exam and got 58.53% as an Average ...well i really don't know and it seems that i'm gonna leave JAVA !!! it's too hard...for non-programmer.
Deepak Bala wrote:
Suresh Babu Venkat wrote:
Darryl Burke wrote:
Prasad Kharkar wrote:the reason is that those objects are stored in the constant pool like String objects
No. Integer caches the values from -128 to 127.
what about Longs?
What happened when your tried the same code but replaced Integer with Long ?
should print not equal according to the rule which you have mentioned as this is Long.But it is returning equal.
the same code prints notequal if we give value as more than 127 .
Darryl Burke wrote:
Prasad Kharkar wrote:the reason is that those objects are stored in the constant pool like String objects
No. Integer caches the values from -128 to 127.