Bookmark Topic Watch 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis
  • Mark post as helpful
  • send pies
  • Report post to moderator
How to access servlet init parameters using EL?

You cannot use the following syntax to access servlet init parameters:

You cannot get Servlet init parameters using this technique. The getInitParameter(java.lang.String name) does not fit in this case, because it requires some arguments.

According to the JavaBean spec, the property has getter & setter methods in the form

Now consider the pageContext as bean Object. The PageContext class has methods like getServletConfig(), getRequest(), getSession() etc. You can access these like pageContext.pageConfig, pageContext.request etc in EL.

ServletContext object has a couple of methods like getMajorVersion(), getMinorVersion() with no args. so we can access these methods treating it as properties to sevletContext bean as pageContext.servletContext.majorVersion and pageContext.servletContext.minorVersion.

If you want to access Servlet init parameters using EL, then it is better to create a Map of the init parameters for the servlet and place it in the request as a scoped variable -- let's say initParameters. You would then be able to obtain any param by name with ${}.


We can access context init parameters with ${}

It means our mission is in jeapordy! Quick, read this tiny ad!
ScroogeXHTML - small and flexible RTF to HTML converter library
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!