| | |
<jsp:include> Not Printing On Web Page, But In Source Code
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Hi there,
I just had a friend install Tomcat for me on my Apache server at school and it's working great with the test .jsp page I created... until I started to use the <jsp:include> tag. Here's my source for "index.jsp":
Here's my source for "inc/header.jsp":
When I load the page in a browser... "This is an include from the 'inc' directory!" does NOT show up on the page. However, if I view said page's source, I see this:
Can anyone please tell me why my include ("This is an include from the 'inc' directory!") is NOT being rendered on the web page... yet appears in its source? Thank you,
CabG
I just had a friend install Tomcat for me on my Apache server at school and it's working great with the test .jsp page I created... until I started to use the <jsp:include> tag. Here's my source for "index.jsp":
JSP Syntax (Toggle Plain Text)
<html> <head> <% String title = "Hello World!"; %> <title><%= title %></title> </head> <body> <h1><%= title %></h1> <jsp:include page="inc/header.jsp" flush="true" /> </body> </html>
Here's my source for "inc/header.jsp":
JSP Syntax (Toggle Plain Text)
This is an include from the "inc" directory!
When I load the page in a browser... "This is an include from the 'inc' directory!" does NOT show up on the page. However, if I view said page's source, I see this:
JSP Syntax (Toggle Plain Text)
<html> <head> <title>Hello World!</title> </head> <body> <h1>Hello World!</h1> This is an include from the "inc" directory! </body> </html>
Can anyone please tell me why my include ("This is an include from the 'inc' directory!") is NOT being rendered on the web page... yet appears in its source? Thank you,
CabG
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Well,
I'm not sure why, but out of desperation I threw this:
below this:
And it's working; even after I took "<%@ include file='inc/header.jsp' %>" back out of the code. I must have done something wrong, initially? I also removed the first "/" from my original:
To make it:
But I thought I'd done that before, too. If anyone has any insight as to why it began to work after I added (then removed) the new code... love to hear it, as a new guy.
CabG
I'm not sure why, but out of desperation I threw this:
JSP Syntax (Toggle Plain Text)
<%@ include file='inc/header.jsp' %>
below this:
JSP Syntax (Toggle Plain Text)
<jsp:include page="inc/header.jsp" flush="true" />
And it's working; even after I took "<%@ include file='inc/header.jsp' %>" back out of the code. I must have done something wrong, initially? I also removed the first "/" from my original:
JSP Syntax (Toggle Plain Text)
<jsp:include page="/inc/header.jsp" flush="true" />
To make it:
JSP Syntax (Toggle Plain Text)
<jsp:include page="inc/header.jsp" flush="true" />
But I thought I'd done that before, too. If anyone has any insight as to why it began to work after I added (then removed) the new code... love to hear it, as a new guy.
CabG
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Well,
I thought I'd figured it out, but it seems that includes DO NOT work within any pages that are not at the root level. Within a page two directories down from the root level (/admin/admin.jsp), none of the following single statements work:
I have this setup in the Tomcat "server.xml" file:
This is a sample of errors with "../../":
And his is a sample of errors with "/":
Can anyone tell me what's wrong? I don't understand why I cannot include files within files that DO NOT reside at the root level.
Thanks so much in advance,
CabG
I thought I'd figured it out, but it seems that includes DO NOT work within any pages that are not at the root level. Within a page two directories down from the root level (/admin/admin.jsp), none of the following single statements work:
JSP Syntax (Toggle Plain Text)
<jsp:include page="/inc/global_header.jsp" flush="true" /> or <jsp:include page="../../inc/global_header.jsp" flush="true" /> or <jsp:include page="/home/projects/www.website.com/htdocs/inc/global_header.jsp" flush="true" /> or <%@ include file="/inc/global_header.jsp" %> or <%@ include file="../../inc/global_header.jsp" %> or <%@ include file="/home/projects/www.website.com/htdocs/inc/global_header.jsp" %>
I have this setup in the Tomcat "server.xml" file:
JSP Syntax (Toggle Plain Text)
<Host name="www.website.com" debug="0" appBase="/home/projects/www.website.com/htdocs"> <Context path="" docBase="/home/projects/www.website.com/htdocs" debug="0" reloadable="true"> </Context>
This is a sample of errors with "../../":
JSP Syntax (Toggle Plain Text)
org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/admin/../../inc/global_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) org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/admin/../../inc/global_header.jsp" not found org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86) org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:339) org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:372) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:484) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552) org.apache.jasper.compiler.Parser.parse(Parser.java:126) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155) org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303) 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)
And his is a sample of errors with "/":
JSP Syntax (Toggle Plain Text)
org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/inc/global_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) org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/inc/global_header.jsp" not found org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86) org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:339) org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:372) org.apache.jasper.compiler.Parser.parseDirective(Parser.java:484) org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552) org.apache.jasper.compiler.Parser.parse(Parser.java:126) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155) org.apache.jasper.compiler.Compiler.compile(Compiler.java:295) org.apache.jasper.compiler.Compiler.compile(Compiler.java:276) org.apache.jasper.compiler.Compiler.compile(Compiler.java:264) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303) 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)
Can anyone tell me what's wrong? I don't understand why I cannot include files within files that DO NOT reside at the root level.
Thanks so much in advance,
CabG
•
•
Join Date: Sep 2006
Posts: 4
Reputation:
Solved Threads: 0
Okay,
In what's becoming a habit, I'm answering my own questions. Yay! Here's what helped me (in particular, Comment #5):
Include File Failure for Parent|Top Relative References
http://issues.apache.org/bugzilla/show_bug.cgi?id=39817
My only question, from an inquisitive nature: why did changing my subfolder directory's name (where my subdirectory files reside) from "code" to "ROOT" make it work? Does Tomcat look for "ROOT" and allow directory-scaling (up, I mean) only when items are in a subfolder called "ROOT?"
Thanks,
CabG
In what's becoming a habit, I'm answering my own questions. Yay! Here's what helped me (in particular, Comment #5):
Include File Failure for Parent|Top Relative References
http://issues.apache.org/bugzilla/show_bug.cgi?id=39817
My only question, from an inquisitive nature: why did changing my subfolder directory's name (where my subdirectory files reside) from "code" to "ROOT" make it work? Does Tomcat look for "ROOT" and allow directory-scaling (up, I mean) only when items are in a subfolder called "ROOT?"
Thanks,
CabG
![]() |
Similar Threads
- how do i write the code for taking out a hard copy of the web page (HTML and CSS)
- help!..VerySimple web browser(display source code of web pages) (JSP)
- Downloading web page source. (C)
- Change Web Page Font Size on the Fly (Windows tips 'n' tweaks)
- Printing Web Page (Windows 95 / 98 / Me)
Other Threads in the JSP Forum
- Previous Thread: Combo Box In Jsp+ Ajax Urgent Please Help Me
- Next Thread: How To Run A Jsp In The Weblogic
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






