1

I have a jsp file in a directory and I am trying to include another file from a directory above. It works fine in localhost, but when the same file is uploaded to server I get the errors.

My Trials:

Trial 1

<jsp:include page="../top_links.jsp" />

Error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /aboutus.jsp at line 17 (<jsp:include is at line 17)

Trial 2

<jsp:include page="/top_links.jsp" />

Error:

File &quot;/top_links.jsp&quot; not found

Trial 3

<% String myUrl = request.getContextPath() + "/top_links.jsp"; %>
<jsp:include page='<%=myUrl%>' />

Error:

File &quot;/about/top_links.jsp&quot; not found

Please help how to include a jsp file from upper/another directory to current jsp:include. If the file is moved to current working directory then there is no error.

PS: There were many other trials that also lead to undesirable outputs.

Koushik S
  • 11
  • 2
  • What is the absolute path for "top_links.jsp" what is the absolute path for the file that produces the error. is "top_links.jsp" inside the webroot directory? – k3b Dec 02 '13 at 17:35

1 Answers1

0

If by "another directory" you mean another directory within the same app, it should work. If by "another directory" you mean a different app, it is not going to work. Nor should you want it to work in that case, since each app should be segregated as far as the sessions.

In case the terminology is confusing. Folders directly under webapps are apps not regular directories for the purposes of Tomcat (or whatever your servlet container is). Folders under those apps can be thought of simply as directories.

developerwjk
  • 8,619
  • 2
  • 17
  • 33
  • Thank you for your reply. I would like to elaborate a bit. 1. There is a file "top_links.jsp" in home folder of the application. 2. There is a sub directory aboutus which has file "aboutus.jsp". In "aboutus.jsp" I have used jsp include tag like `` When I run "aboutus.jsp" on localhost it works fine. But when I upload it to my service provider I am getting errors as specified above. – Koushik S Dec 03 '13 at 12:41