Page 1 of 1

About Question enthuware.jwpv6.2.1055 :

Posted: Thu Nov 12, 2015 4:53 pm
by renatumb
How about the THIRD answer?

Since:
- HttpServlet extends GenericServlet
- GenericServlet implements Servlet, ServletConfig, java.io.Serializable

So I could call:

Code: Select all

getServletContext().getInitParameter(java.lang.String name) 
So, are there 3 correct answers ? 2nd, 3rd and 4th?

Re: About Question enthuware.jwpv6.2.1055 :

Posted: Thu Nov 12, 2015 8:13 pm
by admin
You want to get the servlet initialization parameter, not the context initialization parameter.
HTH,
Paul.

Re: About Question enthuware.jwpv6.2.1055 :

Posted: Fri Nov 13, 2015 7:43 pm
by renatumb
admin wrote:You want to get the servlet initialization parameter, not the context initialization parameter.
HTH,
Paul.
Yeah, I understood that... But I am saying that there are 3(2nd, 3rd and 4th) answers correct, however the test considers correct only the following 2:

Code: Select all

getServletConfig().getInitParameter("dbname");

Code: Select all

getInitParameter("dbname");
But this one is CORRECT too.. the mock test marks it as wrong:

Code: Select all

getServletContext().getInitParameter("dbname");

Re: About Question enthuware.jwpv6.2.1055 :

Posted: Fri Nov 13, 2015 9:48 pm
by admin
Option 3 i.e. getServletContext().getInitParameter("dbname"); will give you the context initialization parameter, not the servlet initialization parameter, which is what the question requires you to retrieve. So why do you think this is correct?

-Paul.

Re: About Question enthuware.jwpv6.2.1055 :

Posted: Mon Nov 16, 2015 8:53 pm
by renatumb
Sorry, my mistake...

Despite the same signature, the methods:
- String getInitParameter(String) on ServletConfig
- String getInitParameter(String) on ServletContext -

They return different values.

Thanks Paul!