tags:

views:

21

answers:

2

Hi, everyone,

I want to ask a question about the JSP page. I set the project in the following structure in order to manage the project efficiently. When I in the list folder, main.jsp, I set the header as the following

<%@ include file="universe/header.jsp" %>

When I open the main.jsp, It shows the error "cannot find the "jsp/list/universe/header.jsp"

the header.jsp and other classes cannot be read. Can anyone help me to solve the problem? thank you.

Class structure

webapp
|
|-- jsp
    |
    |-- list
    |   |
    |   |--main.jsp
    | 
    |-- universe
        |
        |-- header.jsp
        |-- footer.jsp
+2  A: 

In a JSP include directive the path can be relative to the including page or absolute (then it has to start with a / and belongs to the webapplication root directory).

So in this case you has to set the path either to ../universe/header.jsp or /jsp/universe/header.jsp.

vanje
A: 

It depends if your using the classpath to locate files. if your using classpath to locate your files then it should be inside your class folder

jonney
Sorry, but this is not true for JSP files in a web application. Here JSP files are not only simple resource files to locate. A web application in the JEE context has a defined structure. Look at http://www.jsptube.com/servlet-tutorials/web-application-directory-structure.htmlUsually the /WEB-INF/classes and the JARs in /WEB-INF/lib are in the classpath and JSP files resides always outside of these folders.
vanje