<jsp:include> Not Printing On Web Page, But In Source Code

Reply

Join Date: Sep 2006
Posts: 4
Reputation: CabriniGreens is an unknown quantity at this point 
Solved Threads: 0
CabriniGreens CabriniGreens is offline Offline
Newbie Poster

<jsp:include> Not Printing On Web Page, But In Source Code

 
0
  #1
Sep 13th, 2006
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":

  1. <html>
  2. <head>
  3. <% String title = "Hello World!"; %>
  4. <title><%= title %></title>
  5. </head>
  6.  
  7. <body>
  8. <h1><%= title %></h1>
  9.  
  10. <jsp:include page="inc/header.jsp" flush="true" />
  11. </body>
  12. </html>

Here's my source for "inc/header.jsp":

  1. 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:

  1. <html>
  2. <head>
  3.  
  4. <title>Hello World!</title>
  5. </head>
  6.  
  7. <body>
  8. <h1>Hello World!</h1>
  9.  
  10. This is an include from the "inc" directory!
  11. </body>
  12. </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
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 4
Reputation: CabriniGreens is an unknown quantity at this point 
Solved Threads: 0
CabriniGreens CabriniGreens is offline Offline
Newbie Poster

Re: <jsp:include> Not Printing On Web Page, But In Source Code

 
0
  #2
Sep 13th, 2006
Well,
I'm not sure why, but out of desperation I threw this:

  1. <%@ include file='inc/header.jsp' %>


below this:

  1. <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:

  1. <jsp:include page="/inc/header.jsp" flush="true" />


To make it:

  1. <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
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: <jsp:include> Not Printing On Web Page, But In Source Code

 
0
  #3
Sep 14th, 2006
probably caused a cache somewhere to clear, that's often all there is to it with weird things like that.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 4
Reputation: CabriniGreens is an unknown quantity at this point 
Solved Threads: 0
CabriniGreens CabriniGreens is offline Offline
Newbie Poster

Re: <jsp:include> Not Printing On Web Page, But In Source Code

 
0
  #4
Sep 28th, 2006
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:

  1. <jsp:include page="/inc/global_header.jsp" flush="true" />
  2. or
  3. <jsp:include page="../../inc/global_header.jsp" flush="true" />
  4. or
  5. <jsp:include page="/home/projects/www.website.com/htdocs/inc/global_header.jsp" flush="true" />
  6. or
  7. <%@ include file="/inc/global_header.jsp" %>
  8. or
  9. <%@ include file="../../inc/global_header.jsp" %>
  10. or
  11. <%@ include file="/home/projects/www.website.com/htdocs/inc/global_header.jsp" %>

I have this setup in the Tomcat "server.xml" file:

  1. <Host name="www.website.com" debug="0" appBase="/home/projects/www.website.com/htdocs">
  2. <Context path="" docBase="/home/projects/www.website.com/htdocs" debug="0" reloadable="true">
  3. </Context>

This is a sample of errors with "../../":

  1. org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/admin/../../inc/global_header.jsp" not found
  2. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  3. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
  4. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  5. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  6. javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  7.  
  8. org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/admin/../../inc/global_header.jsp" not found
  9. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
  10. org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
  11. org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
  12. org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:339)
  13. org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:372)
  14. org.apache.jasper.compiler.Parser.parseDirective(Parser.java:484)
  15. org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
  16. org.apache.jasper.compiler.Parser.parse(Parser.java:126)
  17. org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
  18. org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
  19. org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
  20. org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
  21. org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
  22. org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
  23. org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
  24. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
  25. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  26. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  27. javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

And his is a sample of errors with "/":

  1. org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/inc/global_header.jsp" not found
  2. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
  3. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
  4. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  5. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  6. javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  7.  
  8. org.apache.jasper.JasperException: /admin/admin.jsp(27,0) File "/inc/global_header.jsp" not found
  9. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
  10. org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
  11. org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
  12. org.apache.jasper.compiler.Parser.processIncludeDirective(Parser.java:339)
  13. org.apache.jasper.compiler.Parser.parseIncludeDirective(Parser.java:372)
  14. org.apache.jasper.compiler.Parser.parseDirective(Parser.java:484)
  15. org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
  16. org.apache.jasper.compiler.Parser.parse(Parser.java:126)
  17. org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
  18. org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
  19. org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
  20. org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
  21. org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
  22. org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
  23. org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
  24. org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
  25. org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  26. org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  27. 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
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 4
Reputation: CabriniGreens is an unknown quantity at this point 
Solved Threads: 0
CabriniGreens CabriniGreens is offline Offline
Newbie Poster

Re: <jsp:include> Not Printing On Web Page, But In Source Code

 
0
  #5
Sep 28th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC