aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes use EL to access servlet init in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "use EL to access servlet init in web.xml" Watch "use EL to access servlet init in web.xml" New topic
Author

use EL to access servlet init in web.xml

Brenda Kwok
Ranch Hand

Joined: Nov 30, 2004
Posts: 38
How to use use EL to access admin eamil

<servlet>
<init-param>
<param-name>adminemail</param-name>
<param-value>abc@hotmail.com</param-value>
</init-param>
</servlet>


[SCJP,SCWCD,SCBCD,SCEA(PARTI)]
Wasim Ayoubi
Ranch Hand

Joined: Nov 21, 2004
Posts: 46
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>abc@hotmail.com</param-value>
</init-param>
</servlet>

try it and I think everything will be fine.


Wasim Ayoubi<br />SCJA1.0(BETA), SCJP1.4, SCWCD1.4<br />Next ???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use EL to access servlet init in web.xml