struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DHarty" <harty...@db.erau.edu>
Subject ERROR IN:Templates located in WEB-INF?
Date Thu, 05 Jul 2001 18:52:31 GMT
Sorry, I caught an error in the last bit of code I submitted in the previous
reply.
This:

	<template:insert template="../template.jsp">

		<template:put name="body" content = "/project/project_body.jsp"/>

	</template:insert>

should actually be

	<template:insert template="../template.jsp">

		<template:put name="body" content = "project/project_body.jsp"/>

	</template:insert>

note the missing "/" at the bigging of the content value.

I still feel that this is, at best, a poor implementation of templates,
however this is a problem with having to use paths relative to the template
file (vs relative to the "put"ing file) as a whole, and not with using them
in WEB-INF.

D

-----Original Message-----
From: DHarty [mailto:harty944@db.erau.edu]
Sent: Thursday, July 05, 2001 12:36 PM
To: Struts; tcolson@cisco.com; phil southward
Subject: RE: Templates located in WEB-INF?


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:phil.soutward@vs-gruppe.de]
Sent: Wednesday, July 04, 2001 3:58 AM
To: harty944@db.erau.edu; tcolson@cisco.com
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


Mime
View raw message