• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

use EL to access servlet init in web.xml

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to use use EL to access admin eamil

<servlet>
<init-param>
<param-name>adminemail</param-name>
<param-value>[email protected]</param-value>
</init-param>
</servlet>
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brenda

I did not find any direct way to access the Servlet Init Param from EL but you can still do it using EL functions you can do this --->

---------------------------------------------------------------
Create a class and define the following function

package whatever;
public class ELFunctions {
public static String getInitParam(PageContext pageContext, String key){
return pageContext.getServletConfig().getInitParameter(key);
}
}
---------------------------------------------------------------
define a whatever.tld file, it should look like this

<uri>http://www.wia.com/el/functions</uri>;
<function>
<name>getInitParameter</name>
<function-class>whatever.ELFunctions</function-class>
<function-signature>java.lang.String getInitParam(javax.servlet.jsp.PageContext, java.lang.String)</function-signature>
</function>
---------------------------------------------------------------
in your jsp file
<%@taglib uri="http://www.wia.com/el/functions" prefix="wia"%>

<h2>${wia:getInitParameter(pageContext,"adminemail")}</h2>

--------------------------------------------------------------
your dd file looks like this
<servlet>
<init-param>
<param-name>adminemail</param-name>
<param-value>[email protected]</param-value>
</init-param>
</servlet>

try it and I think everything will be fine.
reply
    Bookmark Topic Watch Topic
  • New Topic