Hi guys,

Having some real problems with paths in my Faces app for some reason!

I am using Oracle App Server 10g 10.1.2 with MyFaces 1.1.0, JSP 1.2 &
Web-app 2.3. Wish I could use Web-app 2.4 but 10.1.2 does not support
it, and it requires DTDs in config xml files etc. Lots of fun.

File structure:
\index.jsp
\style\css\project.css
\uploadfile.jsp
\results\uploadfile.jsp
\results\pageheader.jsp
\results\externaldata.jsp

I am including pageheader.jsp in each page in my project like so:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"; version="1.2"
          xmlns:f="http://java.sun.com/jsf/core";
          xmlns:h="http://java.sun.com/jsf/html";
          xmlns:t="http://myfaces.apache.org/tomahawk";>
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:view locale="#{facesContext.externalContext.request.locale}">
<f:loadBundle basename="web.bundles.Messages" var="msg"/>
<html>
  <head>
    <link rel="stylesheet" href="style/css/dcts.css" type="text/css"/>
    <title><h:outputText value="#{msg.title}" /></title>
      </head>
      <body width="100%">
        <jsp:include page="pageheader.jsp" flush="true"/> <!-- or
/results/pageheader.jsp in files in the "root" -->

This works some times but not always. I have also tried /style/ and
../style/ and it does not work every time either. It seems to depend
on where I'm "coming from" ie coming from index.jsp, then calling a
/results/externaldata.jsp with href="style/" works. But then if I'm in
/results/uploadfile.jsp and call /results/externaldata.jsp, then the
href="style/" does not work, and it requires ="../style".

So I have decided to provide the entire path, using Context Path or
something similar.

I have tried:
<link rel="stylesheet" href="<h:outputText
value="#{facesContext.externalContext.requestContextPath}"
/>/style/css/project.css" type="text/css"/>
does not work

<link rel="stylesheet"
href="${facesContext.externalContext.requestContextPath}/style/css/project.css"
type="text/css"/>
does not work

<link rel="stylesheet" href="${pageContext.request.contextPath}
/style/css/project.css" type="text/css"/>
does not work

Also, I'm looking for a "universal" way to refer to this
/results/pageheader.jsp include file. In some places I have to use
/results and in others I can just use pageheader.jsp. There must be a
way to get the my application path (in the file system) and use it in
the jsp:include call rather than sometimes using /results and other
times not.

This seems to be a pretty easy thing, but its not working for me, at
least not consistently.

How are the rest of you doing this?

Thanks.
Wayne

Reply via email to