This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Accessing Servlet init Parameter by Expression language Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Accessing Servlet init Parameter by Expression language" Watch "Accessing Servlet init Parameter by Expression language" New topic
Author

Accessing Servlet init Parameter by Expression language

Arun chauhan
Greenhorn

Joined: Oct 01, 2009
Posts: 2
there is no implicit object in expression language to access Servlet/Jsp init parameter.

though there is one initParam object, but it is a map of ServletContext initParameters.

how can I access Servlet/Jsp init parameter in expression language (ie. map of ServletConfig initParameters).
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 163

I think using pageContext implicit EL object:
But could not figure out how?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56207
    
  13

Bindu Lakhanpal wrote:Using pageContext implicit EL object:
${pageContext.servletConfig().initParameter("name")}

Nope. You cannot call methods using the EL. Please don't post answers that won't work -- verify them before you post.

There is no way. If you need this information in a JSP (personally, I never have), you'll need to fetch it in the servlet controller and set is as a scoped variable on behalf of the JSP. Or, you could write a custom tag or EL function.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

I think using pageContext implicit EL object:
But could not figure out how?


Nope . this will not work. Refer this
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 163

Yes, i got that before your posting.And edited my message.
Sorry for mistake
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56207
    
  13

Please check before posting. You can waste a lot of people's time posting incorrect answers.
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 163

Yes,Offcourse sir .
Got my lesson today.
Thanks for correcting me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56207
    
  13

No problem. After all, we are all here to learn!
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Bear Bibeault wrote:Please check before posting. You can waste a lot of people's time posting incorrect answers.


Sure it does.
Bindu Lakhanpal
Ranch Hand

Joined: Oct 17, 2008
Posts: 163

Yes,and i will never post while almost asleep.
Anyway,I learn a lot from you all people.
So I should have taken care.
Thanks for being here.
And i am again sorry if i wasted anyone's time.
Won't do that again.
Arun chauhan
Greenhorn

Joined: Oct 01, 2009
Posts: 2
Got It.
Thanks Bear
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Accessing Servlet init Parameter by Expression language
 
Similar Threads
HS&J - How to get JSP init parameters using EL
EL Expresion of request URI
anywhere to set "init-param" type values for a JSP page ?
implicit object doubt
Servlet initParameter in EL