Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JSF Interview Questions and Answers

Question: How to access web.xml init parameters from java code?
Answer: You can get it using externalContext getInitParameter method. For example, if you have:

<context-param>
<param-name>connectionString</param-name>
<param-value>jdbc:oracle:thin:scott/tiger@cartman:1521:O901DB</param-value>
</context-param>
You can access this connection string with:

FacesContext fc = FacesContext.getCurrentInstance();
String connection = fc.getExternalContext().getInitParameter("connectionString");
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook