0

i have a context param as follows:

  <context-param>
    <param-name>myInitParam</param-name>
    <param-value>myValue</param-value>
  </context-param>

i want to get an init param in JSF 1x (exact version is 1.1.02) as follows:

<object>
<param name="HTTPPort" value="#{initParam.myInitParam}" />

but i am getting the compiler error in JSP:

the attributes for a standard action or an uninterpreted tag cannot be deferred expressions

please advise how to get init param in JSF 1x, and what is the reference for EL used in JSF 1x.

Mahmoud Saleh
  • 33,303
  • 119
  • 337
  • 498

1 Answers1

1

The EL variable is correct, but you can't use deferred EL #{} in template text in legacy JSP which is the default view technology in JSF 1.x. This is exactly what the error message is trying to tell you.

You need to print it using a <h:outputText>.

<f:verbatim><param name="HTTPPort" value="</f:verbatim><h:outputText value="#{initParam.myInitParam}" /><f:verbatim>" /></f:verbatim>

(note that I assume that you were already emitting plain HTML using <f:verbatim>)

Yes, that's one line of ugliness, but that's the payoff of using JSP and one of the main reasons why Facelets was introduced.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • is it correct way to get the init param in javascript function as follows: #{initParam.myInitParam} – Mahmoud Saleh May 15 '13 at 10:37
  • EL doesn't run in JavaScript. EL can however be used to print JavaScript code. Rightclick and *View Source* in browser to see the enlightment that JSF is in this context merely a HTML/CSS/JS code generator. – BalusC May 15 '13 at 10:39
  • i am trying to get init param in javascript function as follows but it always returns blank although the param exists and the name is correct `var strHostIP = "";` please advise why it's not working. – Mahmoud Saleh May 18 '13 at 08:17