Sudhakar Sharma wrote:How would i get servlet-config parameters in a jsp through EL?
For which servlet? As a JSP can be forwarded to by any number of controller servlets, it's not clear what you are trying to accomplish. Please elaborate.
P.S. Please end questions with a single question mark.
Thanks for the link, it means we cannot able to use EL in that way as in getting request's method like
${pageContext.request.method}
then how can i access that, initParam is built for the context, is there anything to the rescue?
Here is the detailed question
I 'm using a.jsp in my app and sets it's <init-param> in <servlet> in the DD, now i wanted to access this param-value in a.jsp using EL
is it possible or not ?
This message was edited 1 time. Last update was at by Sudhakar Sharma
Bear Bibeault
Author and opinionated walrus
Marshal
You still haven't answered my question. Are you talking about context parameters, or a particular servlet's init parameter? If the later, what is the relationship between the servlet and the JSP?
Bear Bibeault wrote:You still haven't answered my question. Are you talking about context parameters, or a particular servlet's init parameter? If the later, what is the relationship between the servlet and the JSP?
I am configuring the a.jsp file in DD with <init-param> now is there any way to access this init parameter in a.jsp through EL
Bear Bibeault
Author and opinionated walrus
Marshal
Bear Bibeault wrote:You still haven't answered my question. Are you talking about context parameters, or a particular servlet's init parameter? If the later, what is the relationship between the servlet and the JSP?
I am configuring the a.jsp file in DD with <init-param> now is there any way to access this init parameter in a.jsp through EL
Bear Bibeault is asking that you are using
<context-param>
<param-name>context</param-name>
<param-value>yes</param-value>
</context-param>
or
<servlet>
<init-param>
<param-name>context</param-name>
<param-value>yes</param-value>
</init-param>
</servlet>
it's the same for the <param-name>,<param-value>.
I think, he asked about the JSP initialization parameters declared in web.xml. Since we need pass the parameter's literal name to the method, we can't use El. Please confirm!
I would venture that if you need to do this, you are likely violating proper Separation of Concerns in your JSP. It's much more likely that good practices would have you associating the init parameters with the servlet controller for the JSP.
A cheap work around would be use a tld file that maps getInitParameterName of ServletConfig as an el function. Then you can include that TLD in your jsp and invoke the function using EL and also pass it the param name. However, as suggested by Bear, the parameters could rather be set as attributes on may be the request scope in the controller servlet which calls the jsp page.
SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
subject: Accessing servlet-config parameter through EL