aspose file tools*
The moose likes JSF and the fly likes jsf in a jsp:include doesn't work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf in a jsp:include doesn Watch "jsf in a jsp:include doesn New topic
Author

jsf in a jsp:include doesn't work?

Saskia de Jong
Ranch Hand

Joined: Jan 24, 2006
Posts: 34
Using MyFaces on Tomcat 5.5 I tried a very basic example where I have one JSP (itest.jsp) page that only contains a single line:



The referenced jsf file only contains a <f:view> en some <h utputText> elements. What happens is a bizare kind of recursion. A couple of hundred lines appear in my log. It start with 10's of:



Then the following pattern which is also repeated hundreds of lines:



For some reason the JSF servlet causes a call to my jsp page again after the include tag has been processed. I'm not really sure why this happens. Is there a 'rule' somewhere that sais I'm not allowed to do this? I'm aware of the fact that JSTL and JSF are a bad mix, but I've never read anything about jsp:include in this situation.

For using jsp:include inside a jsf page, the subview tag needs to be used. Although this is not exactly the same situation, I nevertheless tried that. But this also did not help and again the weird kind of recursion happened.
[ February 03, 2006: Message edited by: Saskia de Jong ]
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
Why do you try /jsftest2.jsf, but not /jsftest2.jsp ?
Saskia de Jong
Ranch Hand

Joined: Jan 24, 2006
Posts: 34
Originally posted by Sergey Smirnov:
Why do you try /jsftest2.jsf, but not /jsftest2.jsp ?


Since jsftest2.jsp is a file containing JSF tags. If I use the name jsftest2.jsp in the include tag, then it's not going through the JSF servlet. In my setup *.jsf files are mapped to the JSF servlet.

Nevertheless I did try to use jsftest2.jsp, but then I just get a msg that JSF is not initialized.
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
I think the issue here is that the include doesn't issue or create an http request. Thus it isn't filtered through the faces servlet. Hence your .jsf isn't read by the servlet as it is included.

Then if you include the jsf in the jsp, but then call the the itest.jsp instead of itest.jsf it doesn't get filtered by the servlet either. So the faces tags included by jsftest2.jsp (or in your case jastest2.jsf) are not interpreted by the faces servlet either. Since jsp are not filtered through it.

Try this. Do the include as:

<jsp:include page="/jsftest2.jsp" />

Note that I'm calling jsp NOT jsf

Then open

itest.jsf NOT itest.jsp

in the browser

and see what happens. Hope that fixes it.
arjan tijms
Greenhorn

Joined: Jan 22, 2006
Posts: 5
Originally posted by Gerardo Tasistro:
I think the issue here is that the include doesn't issue or create an http request. Thus it isn't filtered through the faces servlet. Hence your .jsf isn't read by the servlet as it is included.


I'm not really sure if that is the issue. If I look at the given stack trace I see a "at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)" line there, so the include surely causes the JSF servlet to be invoked.

I quickly tried the same setup (also tomcat and myfaces), and there's indeed an endless recursion happening. I also tried your solution and it did work, so the OP's problem is solved I think. Nevertheless I'm curious about what is exactly happening here.

It would be interesting to step through the tomcat source (JspServlet would be a candidate) with a debugger to get to the bottom of this. Maybe if I'll have some time tomorrow I'll try to do this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsf in a jsp:include doesn't work?