Templates located in WEB-INF?
Is it possible to "hide" all JSP files under the /WEB-INF/ directory and still use templates?? I had some difficulties with the following code finding the "main_content.jsp" page. Should this work or am I trying to do something that is known to not work? (BTW - The code seems to run fine if I put the /jsp directory inside the context root.) Thanks! Tim Colson <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %>
RE: Templates located in WEB-INF?
Where is you template file (WEB-INF)? If it is, rry using relative paths to put to the template. ex: the line in "project.jsp" that puts to the template... where the path is relative to the template NOT to the "put"ing file. Let me know this works, or I'll have a hell of a time when I deploy. D -Original Message- From: Tim Colson [mailto:[EMAIL PROTECTED]] Sent: Monday, July 02, 2001 2:48 PM To: [EMAIL PROTECTED] Subject: Templates located in WEB-INF? Is it possible to "hide" all JSP files under the /WEB-INF/ directory and still use templates?? I had some difficulties with the following code finding the "main_content.jsp" page. Should this work or am I trying to do something that is known to not work? (BTW - The code seems to run fine if I put the /jsp directory inside the context root.) Thanks! Tim Colson <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %>
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: 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: 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: 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: 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
FW: Templates located in WEB-INF?
>I haven't tried to replicate DH's methods on my own stuff yet... but it's of >interest to note that the files must be specified relative to the template >rather than relative to the initial JSP. Its also of interest to note that if you call resources directly from the template file, (ex: mailto:[EMAIL PROTECTED]] Sent: Thursday, July 05, 2001 10:17 PM To: phil southward; [EMAIL PROTECTED] Subject: RE: Templates located in WEB-INF? Phil / DH - Phil wrote: > "The other files, contained within the WEB-INF directory, are resources > accessible only to the container" Apologies for not replying sooner - this is somewhat moot as DH replied with a few other path options that apparently work. ;-) WEB-INF is indeed private and can only be accessed by the container (The Servlet Spec 2.2 is quite handy to have printed out IMHO.) However, the template TLD is running inside that container and therefore should have access. I haven't tried to replicate DH's methods on my own stuff yet... but it's of interest to note that the files must be specified relative to the template rather than relative to the initial JSP. Thanks DH for the info - I'll give it a try and reply back with results. ;-) Cheers, Timo (BTW - I've been fighting with another issue involving getting the value of "j_username" to put into my login error.jsp page so the user can try again. Ugh. No mention of this one in the Servlet spec. <%= request.getParameter("j_username") %> returns 'null' fyi.)