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 "/top_links.jsp" not found
Trial 3
<% String myUrl = request.getContextPath() + "/top_links.jsp"; %>
<jsp:include page='<%=myUrl%>' />
Error:
File "/about/top_links.jsp" 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.
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.