• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on implicit objects in EL?

 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever notice that there is no EL implicit object equivalent to 'config' implicit object in jsp? so how does EL get the JSP init parameters??
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there's implicit object initParam for this.
 
Paolo Metafune
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergey, i think your answer isn't correct.
In jsp we have the "config" implicit object that implements javax.servlet.ServletConfig and so permits to retrieve servlet configuration parameters and not context parameters.

In EL we have initParam implicit object that, as JSP specification says, is a Map that maps context initialization parameter names to their string parameter values (obtained by calling ServletContext.getInitParameter(String name)). So it retrieves context and not servlet parameters.


Let me know your opinion.
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where I can specify JSP init parameters?
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, you're right. I get the question wrong. initParam implicit object is used to get ServletContext's init parameters, not servlets.
We can get ServletConfig by ${pageContext.servletConfig} but there is no way to get init parameter from ServletConfig, as we can't get method getInitParameter(String name) from EL expression.
I must say, that i would also like to see the approach for getting JSP init parameters.
 
Paolo Metafune
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
you can specify jsp init parameter in web.xml like this:

<servlet>
<servlet-name>MyServlet</servlet-name>
<jsp-file>/MyJSPFile.jsp</jsp-file>
<init-param>
<param-name>parName</param-name>
<param-value>parValue</param-value>
</init-param>
</servlet>

you can also define a mapping as you normally do for servlets(i mean using the same configuration tags)
[ September 01, 2005: Message edited by: Paolo Metafune ]
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paolo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic