aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Access application context using EL 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 "Access application context using EL " Watch "Access application context using EL " New topic
Author

Access application context using EL

Ramprasad Subburaman
Greenhorn

Joined: Dec 18, 2005
Posts: 19
I have declared an application context parameter as below in web.xml

<web-app>
<context-param>
<param-name>email</param-name>
<param-value>sramprasad@gmail.com</param-value>
</context-param>
</web-app>

I am able to access the param and print using

<%=application.getInitParameter("email")%>

In the same lines, can anyone tell me how to access and print using EL.
Ashley Bideau
Ranch Hand

Joined: Apr 22, 2006
Posts: 40
You can use EL implicit object "initParam" to retrieve the value like this in jsp



-Ashley
janne jounivich
Ranch Hand

Joined: Jan 11, 2005
Posts: 45
or you can use also
the following kind of EL
syntax ..

${initParam["email"]} or
${initParam['email']}

JR
[ May 10, 2006: Message edited by: janne RockGulf ]

----
Ramprasad Subburaman
Greenhorn

Joined: Dec 18, 2005
Posts: 19
Thanks for your replies.

Actually, I had a problem with EL.

when u have <%@page isELIgnored="false"%> then u can't use



You will get an error "attribute value does not accept any expressions"


Hope the above observation is usefull to all.
[ May 11, 2006: Message edited by: Ramprasad Subburaman ]
Ashley Bideau
Ranch Hand

Joined: Apr 22, 2006
Posts: 40
Mr Ram your observation is not RIGHT !!!
Try below code and let me know what you see in your browser.




In your web.xml file



P:S I have to give "space" between "<c: out" tag otherwise you will see some nice image . So remove the same in your jsp.

-Ashley
SCJP 5.0
[ May 11, 2006: Message edited by: Ashley Bideau ]
Ramprasad Subburaman
Greenhorn

Joined: Dec 18, 2005
Posts: 19
Thanks Ashley.
Yesterday, I made a mistake in the <c: out> tag.

Thank you for correcting me.


Ramprasad
[ May 11, 2006: Message edited by: Ramprasad Subburaman ]
 
Don't get me started about those stupid light bulbs.
 
subject: Access application context using EL