About Question enthuware.jwpv6.2.1055 :

Moderator: admin

Post Reply
renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

About Question enthuware.jwpv6.2.1055 :

Post 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?

Online
admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1055 :

Post by admin »

You want to get the servlet initialization parameter, not the context initialization parameter.
HTH,
Paul.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.jwpv6.2.1055 :

Post 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");

Online
admin
Site Admin
Posts: 10384
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1055 :

Post 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.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

Re: About Question enthuware.jwpv6.2.1055 :

Post 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!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests