You have built a web application that you license to small businesses. The webapp uses a context
parameter, called licenseExtension, which enables certain advanced features based on your
client’s license package. When a client pays for a specific service, you provide them with a license
extension key that they insert into the <context-param> of the deployment descriptor. Not every
client will have this context parameter so you need to create a context listener to set up a default
value in the licenseExtension parameter.
Which code snippet will accomplish this goal?
A.
You cannot do this because context parameters CANNOT be altered programmatically.
B.
String ext = context.getParameter(‘licenseExtension’);if ( ext == null ) {
context.setParameter(‘licenseExtension’ DEFAULT);}
C.
String ext = context.getAttribute(‘licenseExtension’);if ( ext == null ) {
context.setAttribute(‘licenseExtension’ DEFAULT);}
D.
String ext = context.getInitParameter(‘licenseExtension’)if ( ext == null ) {
context.resetInitParameter(‘licenseExtension’ DEFAULT);}
E.
String ext = context.getInitParameter(‘licenseExtension’)if ( ext == null ) {
context.setInitParameter(‘licenseExtension’ DEFAULT);}
E
E
E
E, NEXT !!
yes it’s E
Yes, the answer is E because context.resetInitParameter does not exist !!
yes its true, context.resetInitParameter does not exist !
The correct answer should be A because if the context parameter already exists with that name you cannot modify it:
http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#setInitParameter(java.lang.String, java.lang.String)
Reading better the question the context parameter could not exist, the condition in the E option prevents the exception case. E
Answer not have ‘;’ String ext = context.getInitParameter(‘licenseExtension’)???????if ( ext == null )
answer is A.
Answer seems to be A
http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html#setInitParameter(java.lang.String, java.lang.String)