• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Include Jsp in Jsp

 
Raj Maheshwari
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1782
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic