2

I'm trying to run my project (normally working on tomcat7) on tomcat6. But JSF can't call methods with parameters now, e.g.

<h:commandLink action="#{bean.setpage('index')}"/>

It works normally on Tomcat7..

Is it possible to call method with parameter on tomcat6?

UPDATE: both answers bellow are correct, and i also had to update context.xml:

<context-param>
    <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
</context-param>
gaffcz
  • 3,469
  • 14
  • 68
  • 108

2 Answers2

2

If you are using a container which supports JSF 2.0 completely, you can directly do

<h:commandLink action="#{bean.setpage('index')}"/>.

Else you have to use f:param or f:attribute. I think Tomcat 7 supports jsf 2 completely but Tomcat 6 does not support out of the box. So you have to add jstl-api-1.2.jar, jstl-impl-1.2.jar and el-impl-2.2.jar libraries to make it work on Tomcat 6.

Narendra Yadala
  • 9,554
  • 1
  • 28
  • 43
  • @gaffcz If you add the JSTL 1.2 libary and el-impl-2.2.jar to the WEB-INF/lib and it should work on Tomcat 6 as well. – Narendra Yadala Oct 27 '11 at 08:50
  • Thank you. And add those libs to lib of project or to tomcat6/lib directory? – gaffcz Oct 27 '11 at 09:03
  • @gaffcz `el` libraries to tomcat6/lib and `jstl1.2` libraries to project lib. – Narendra Yadala Oct 27 '11 at 09:05
  • Still doesn't work :( `SEVERE: Servlet.service() for servlet Faces Servlet threw exception org.apache.el.parser.ParseException: Encountered " "(" "( "" at line 1, column 22. Was expecting one of: "}" ...` – gaffcz Oct 27 '11 at 09:36
  • @gaffcz By the way did you remove the existing `el` jar file that is already there in Tomcat 6 dist. Anyways, if you have a lot of time you can try and get it working on Tomcat 6, but otherwise I would suggest using one of the methods given here for passing parameters from page to bean http://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ – Narendra Yadala Oct 27 '11 at 09:43
  • :) time is problem.. I've removed the old `el-api.jar` and also `jasper-el.jar`. Replaced them by `el 2.2 api` and `impl`, and add `jstl 1.2 api` and `impl` to my `lib` folder. And it's still the same... – gaffcz Oct 27 '11 at 09:57
1

yes it is, just check that u have the right the el and el-impl jars in the lib folder of tomcat. (2.2 i think)

Khizar
  • 2,288
  • 5
  • 32
  • 53