Charlie Harper
Charlie Harper

Reputation: 379

Java EE - change directory of index.jsp

my structure of .jsp files is: WEB-INF/jsp/....; but i have the index.jsp file in WEB-INF/index.jsp folder. As well i have also another types of files in directory WEB-INF/, i would like to move the index.jsp into the folder like this: WEB-INF/jsp/index.jsp. So can i somehow change (in my conf files - not in tomcat settings) that my index page is in another folder? i tried to use this:

<welcome-file-list>
    <welcome-file>jsp/index.jsp</welcome-file>
</welcome-file-list>

and many variatons of welcome-file-list but i didnt get working combination.

Upvotes: 0

Views: 2511

Answers (2)

SparkOn
SparkOn

Reputation: 8956

I dont think jsp or any other user-interactive things should be placed inside the WEB-INF as it is not a good practice, it is private and secure part of the application. Only the .class files,libraries and deployment descripter resides there. Alternatively what you can do is create folder named jsp under web-content and place your jsp files there.

Well even though if you want to do it try like this:

<welcome-file-list>
    <welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
</welcome-file-list>

will work if jsp is folder under WEB-INF

Upvotes: 1

Braj
Braj

Reputation: 46871

A JSP file placed under WEB-INF can't accessed directly by simply hitting the URL, it can be accessed only by the application itself.

The WEB-INF is more secure way for restricted resources that can't accessed publically.

Read What is WEB-INF used for in a Java web application?


Redirect, Include or Forward the request form index.jsp to the requested JSP page.

For example :

Create index.jsp directly placed under webcontent folder and include the WEB-INF/jsp/index.jsp.

webcontent/index.jsp:

<%@ include file="WEB-INF/jsp/abc.jsp" %> 

Upvotes: 1

Related Questions