views:

39

answers:

1

I just created a new IceFaces application and I'm trying to include a navigation bar in all of the pages. When I use the jsp:directive.include tag the file is included, but when I use jsp:include it does not seem to be loaded. In fact, when I check the HTML source code in my browser, it's like the included file was completely empty. I do not want to use jsp:directive.include because it will not automatically show any updates to the included file.

My environment: Eclipse 3.5, Tomcat 6, JSF 1.2, IceFaces 1.8.

Steps to reproduce the problem and pieces of code:

  1. create a new Dynamic Web Project with the following options: Target runtime: Apache tomcat v6.0 Dynamic web module version: 2.5 Configuration: ICEfaces project

  2. create a new ICEFaces JSPX file -- the home file. Some code:

    <jsp:directive.page contentType="text/html;charset=ISO-8859-1" />
    
    
    <f:view >
        <ice:outputDeclaration doctypeRoot="HTML"
            doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
            doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" />
        <html>
        <head>
        <title>test file</title>
        <link rel="stylesheet" type="text/css"
            href="./xmlhttp/css/rime/rime.css" />
        </head>
        <body>
            <jsp:directive.include file="./vertical_navigation.jsp" /> <!-- working -->
            <jsp:include page="./vertical_navigation.jsp" /> <!-- not working, no error though -->
        </body>
        </html>
    </f:view>
    

  3. create the file to be included, also as a new ICEFaces JSPX file. Simplified code:

        <ice:form>
            <ice:panelGrid columns="1" width="152">
            <ice:graphicImage url="./img/image.jpg"></ice:graphicImage>
            <ice:panelCollapsible expanded="true">
                <f:facet name="header">
                    <ice:panelGroup>
                        <ice:outputText value="Customer"/>
                    </ice:panelGroup>
                </f:facet>
                <ice:panelGrid columns="1">
                    <ice:commandLink action="customer"><ice:outputText value="Customer name" /></ice:commandLink>
                </ice:panelGrid>
            </ice:panelCollapsible>
        </ice:panelGrid>
        </ice:form>
        </body>
        </html>
    </f:view>
    

Some remarks:

  1. I'm completely new to JSF, so forgive me for any obvious mistake.
  2. In the home file (the first one) I'm not using both tags at the same time. I pasted both here just to show that I am trying both options.
  3. I created both files as "ICEFaces JSPX file", but the second one was assigned the .jsp extension.
  4. When I use the directive.include tag, the included file is loaded. But if I change it, it's not automatically republished.
+1  A: 

To start, you have to separate and distinguish several technologies:

  • JSP is a Java based view technology which allows you to write HTML/CSS/JS in and use taglibs to call backend Java code and/or control the output flow.

  • JSPX is the same as JSP, but forces you to write code in XML format. JSP-specific tags are replaced by tags in XML format. JSPX is also called "JSP Document". Here is a basic tutorial which outlines the differences in tags.

  • JSF is a component based MVC framework which provides components in flavor of taglibs which outputs HTML/CSS/JS.

You cannot use <jsp:include> in a JSPX page. You have to transform the JSPX page into a JSP page. You need to rename the file .jspx to .jsp and replace JSPX specific tags by JSP tags. Here's a kickoff example for JSP with JSF/IceFaces:

<%@ page pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://www.icesoft.com/icefaces/component" prefix="ice"%>
<!DOCTYPE html>
<f:view>
    <html lang="en">
        <head>
            <title>Title</title>
        </head>
        <body>
            <jsp:include page="include.jsp" />
        </body>
    </html>
</f:view>
BalusC
the reason is not clear for me, but I found some documentation stating that we should not use jsp:include in icefaces: http://www.icefaces.org/docs/v1_8_2/htmlguide/devguide/references2.html
Paulo Guedes
Because they strongly encourage XML markup. By the way, have you looked at [Facelets](http://facestutorials.icefaces.org/tutorial/facelets-tutorial.html)? It's roughly said an extension on JSPX and since Java EE 6 the successor of JSP. There's an `<ui:include>`.
BalusC
@BalusC Yes, I'm trying to use Facelets, but I'm a little but confused yet. Anyway, I'm not using jsp:include anymore. jsp:directive.include works fine and refreshing any changed file is not so important.
Paulo Guedes