About Question enthuware.jwpv6.2.1214 :

Moderator: admin

Post Reply
ETS User

About Question enthuware.jwpv6.2.1214 :

Post 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

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

Re: About Question enthuware.jwpv6.2.1214 :

Post 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.
If you like our products and services, please help us by posting your review here.

victor2016
Posts: 18
Joined: Wed Jan 20, 2016 7:16 pm
Contact:

Re: About Question enthuware.jwpv6.2.1214 :

Post by victor2016 »

What about setInitParameter(java.lang.String name, java.lang.String value) of ServletContext?

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

Re: About Question enthuware.jwpv6.2.1214 :

Post 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)
If you like our products and services, please help us by posting your review here.

victorsk2015
Posts: 5
Joined: Sat Dec 05, 2015 7:49 pm
Contact:

Re: About Question enthuware.jwpv6.2.1214 :

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

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests