File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL- getting JSP Init Param Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL- getting JSP Init Param" Watch "EL- getting JSP Init Param" New topic
Author

EL- getting JSP Init Param

Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
Hi Rancher

In EL, We have initParam implicit object for getting context init params. How can we get JSP init params using EL.

Thanks


"Know where to find the solution and how to use it - that's the secret of success."
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

What are you calling JSP init params ?


[My Blog]
All roads lead to JavaRanch
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
We can define init-params for a jsp page using following


Can we access these params using EL
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Yes. These are called servlet init parameters. You're pointing to a JSP page, but it's still a servlet, so you can access them like any other servlet init params.
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329

Yes, but how about achieving it without using scripting at all (EL + JSTL)?

The only thing I can think of doing is to use ${pageContext.servletConfig.initParameterNames} to retrieve a java.util.Enumeration object containing the servlet's init parameters' names. And then what? How would you call pageContext.getServletConfig().getInitParameter(java.lang.String name) without using scripting?

Or is it not possible?
[ March 23, 2007: Message edited by: Sergio Tridente ]

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Tridib Samanta
Ranch Hand

Joined: Apr 28, 2004
Posts: 128
Anybody have any definite answer on above mentioned problem?

What I can think write now is to write an EL Function which takes config and parameter name as input and returns the value.


Thanks, Tridib
SCJP 1.4, SCWCD 1.4, SCBCD 5.0
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I was a bit quick one that one, sorry
That's right, you can't access them directly.

http://faq.javaranch.com/view?InitParamsThruExpressionLanguage
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: EL- getting JSP Init Param