Page 1 of 1

About Question enthuware.jwpv6.2.1214 :

Posted: Sun May 20, 2012 3:30 pm
by ETS User
Given the following line of code in a servlet:
String dburl = getServletContext().getInitParameter("DBURL");

The web.xml for this web application contains the following:
<context-param>
<param-name>DBURL</param-name>
<param-value>jdbc:odbc:MySQLODBC</param-value>
</context-param>

Which of the following statements are correct?

The following was given as the solution:
The value for DBURL cannot be changed programmatically.
Where is the value being changed programmatically, or at all?
Rob Millican
rbmillican@hotmail.com

Re: About Question enthuware.jwpv6.2.1214 :

Posted: Sun May 20, 2012 4:58 pm
by admin
It is not being changed in the given code. It just shows how DBURL is being retrieved. The statement in the option claims that it cannot be changed programmatically, which is correct.

HTH,
Paul.

Re: About Question enthuware.jwpv6.2.1214 :

Posted: Wed Jan 20, 2016 7:19 pm
by victor2016
What about setInitParameter(java.lang.String name, java.lang.String value) of ServletContext?

Re: About Question enthuware.jwpv6.2.1214 :

Posted: Thu Jan 21, 2016 4:17 am
by admin
setInitParameter works only if a parameter is not set already. It cannot change a value if it is set in the DD.
https://docs.oracle.com/javaee/6/api/ja ... tParameter(java.lang.String, java.lang.String)

Re: About Question enthuware.jwpv6.2.1214 :

Posted: Thu Jan 21, 2016 9:33 am
by victorsk2015
admin wrote:setInitParameter works only if a parameter is not set already. It cannot change a value if it is set in the DD.
https://docs.oracle.com/javaee/6/api/ja ... tParameter(java.lang.String, java.lang.String)
Thank you for your reply. I take this exam this coming Monday so it was important for me to clarify this. Thanks.