aspose file tools*
The moose likes JSP and the fly likes Include Jsp in Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Include Jsp in Jsp" Watch "Include Jsp in Jsp" New topic
Author

Include Jsp in Jsp

Raj Maheshwari
Ranch Hand

Joined: Jul 02, 2004
Posts: 34
Hi,

I am quite new to JSP's and wanted to do the following

I have 1 jsp: login.jsp in com.j2ee.webtier.pages.Login.jsp
I have the second jsp: header.jsp in com.j2ee.webtier.util.header.jsp

My problem is when I do <%include file="/header.jsp" where /header.jsp is the url-pattern in my web.xml, I get a stack exception like:

org.apache.jasper.JasperException: /WEB-INF/classes/com/j2ee/webtier/pages/Login.jsp(44,0) File "/WEB-INF/classes/com/j2ee/webtier/pages/Header.jsp" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

Why is it still looking for the header.jsp in the same hierarchy. I've even imported the util folder.

Thanks
Raj
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
You shouldn't have jsp files under the WEB-INF/classes directory.
That is meant for java classes.

Just put header.jsp in the root directory of your web application (the same folder where the WEB-INF directory is)
Raj Maheshwari
Ranch Hand

Joined: Jul 02, 2004
Posts: 34
Hi Stefan,

So putting my aforementioned jsps in that are in the classes folder, in something like WEB-INF/jsp/FolderA and in WEB-INF/jsp/FolderB would do the trick?

The reason I want this separated is because I want some jsp's to have filters in front of them.

Thanks
Raj
[ April 03, 2006: Message edited by: Raj Maheshwari ]
Raghavendra nandavar
Ranch Hand

Joined: Jun 26, 2005
Posts: 231
Originally posted by Raj Maheshwari:
Hi Stefan,

So putting my aforementioned jsps in that are in the classes folder, in something like WEB-INF/jsp/FolderA and in WEB-INF/jsp/FolderB would do the trick?

The reason I want this separated is because I want some jsp's to have filters in front of them.

Thanks
Raj

[ April 03, 2006: Message edited by: Raj Maheshwari ]



You can add all Jsp's in the root folder itself, Web-Inf folder has all your configuration files and java classes in the respective classes folder. You can create any number of folders for your jsp's in the root folder.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Include Jsp in Jsp