Sangita Hota

Greenhorn
+ Follow
since Jul 03, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sangita Hota

resource-ref or resource-env-ref : are these on exam?
In Mikalai notes under getParameter(String name) method it says:
If the parameter data was sent in the request body, such as occurs with an HTTP POST request, then reading the body directly via getInputStream() or getReader() can interfere with the execution of this method.

What does this mean?
Based on the following information, please construct the full path for the servlet.

Please select one correct answer.

docbase = c:/temp/
context path = /test
alias name = MyMail
servlet-name = com.jiris.common.util.MailServlet
url-pattern = /mail/*

A : c:/temp/mail/com/jiris/common/util/MailServlet.class
B : c:/temp/test/com/jiris/common/util/MailServlet.class
C : c:/temp/mail/test/com/jiris/common/util/MailServlet.class
D : c:/temp/test/mail/com/jiris/common/util/MailServlet.class

I think answer should be "D", but answer is given as "B" and followed by this explanation??

Explanation

The full servlet path is construted as follows:
full path = docbase + context path + url-pattern + Resource

Accordingly, if I want to enable the user to access this servlet, I should complete the following step:

1. Define the servlet in the web.xml file:

<servlet>
<servlet-name>MyMail</servlet-name>
<servlet-class>com.jiris.common.util.MailServlet</servlet-class>
<init-param>
<param-name>smtpServer</param-name>
<param-value>someSmtpServer</param-value>
<description>default smtp server address</description>
</init-param>
</servlet>

2. Define the servlet-mapping in the web.xml file:

<servlet-mapping>
<servlet-name>MyMail</servlet-name>
<url-pattern>/mail/*</url-pattern>
</servlet-mapping>
It's actually getAttributesScope(String name) - u can read as getAttribute'sScope(String name) as this method is used to get the scope of the given attribute.


public abstract int getAttributesScope(String name)Get the scope where a given attribute is defined.

Parameters:
name - the name of the attribute to return the scope for
Returns:
the scope of the object associated with the name specified or 0
Throws:
NullPointerException - if the name is null
import javax.servlet.*;
import javax.servlet.http.*:
public class TestServlet extends HttpServlet implements SingleThreadModel {
private HashMap hm = new HashMap();
public void doGet(HttpServletRequest req, HttpServletResponse res) {
//lot of code.
}
}

Which of the following statements are correct?

a) 'hm' is thread safe
b) 'hm' is not thread safe
c) 'req' is thread safe
d) Making 'hm' static would make it thread safe.
e) 'hm' can be made thread safe only if it is made final.

Ansewrs given is a) and c)

How come a) is correct? In SingleThreadModel it may create more than one instance right??
public void setStatus(int sc)Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there is an error, and the caller wishes to invoke an error-page defined in the web application, the sendError method should be used instead.

public void sendError(int sc)
throws java.io.IOException Sends an error response to the client using the specified status code and clearing the buffer.
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
Free mock questions under Enthuware are as difficult as the real exam questions? (http://jdiscuss.com/Enthuse/jsp/ShowAvailableTests.jsp)
How much should one score in these 5 mock tests?