I was able to successfully use template under WEB-INF, but not as I had
origionally supposed.
Given a template file ("template.jsp" that might look similar to this:
<html>
<!-- body -->
<template:get name='body'/> </td>
</html>
which is located in the "/template" directory (ex
webapps/appdir/templates/).
Also given a page named "project.jsp" in the "/project" directory (ex
webapps/appdir/project/) wich might look like this:
<template:insert template="../templates/template.jsp">
<template:put name="body" content = "../project/project_body.jsp"/>
</template:insert>
This works until you move the pages into the WEB-INF directory ex (ex
webapps/appdir/WEB_INF/pages/). The container has trouble parsing the
nultiple ".." operators. In this case
"../templates/../project/project_body.jsp".
I've found two solutions to this. The first is to put the absolute path in
your "project.jsp" file like so:
<template:insert template="../templates/template.jsp">
<template:put name="body" content =
"/WEB-INF/pages/project/project_body.jsp"/>
</template:insert>
A second solution (my preferrence), is to put the template file in the base
directory of your WEB-INF path that you are using. In this example you
could put the template file into "WEB-INF/pages/", and then your
project.jsp could look like this:
<template:insert template="../template.jsp">
<template:put name="body" content = "/project/project_body.jsp"/>
</template:insert>
You could probably also put the template file directly into the WEB-INF
directory, and adjust your paths accordingly, but I prefer to keep it
separate from the config files etc.
Good luck
D
-----Original Message-----
From: phil southward [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 04, 2001 3:58 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Templates located in WEB-INF?
Guys I had the same problem, I could access pages that were under the root,
but not under WEB-INF. Until I re-read my Wrox Press book (Java Server
Programming, J2EE edition). I quote here,
"The other files, contained within the WEB-INF directory, are resources
accessible only to the container"
In other words, the WEB-INF is a private directory for the Servlet engine
only, if you want to access your JSPs you have to put them either under the
root directory or in sub directories also under root.
Phil