0

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.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Charlie Harper
  • 379
  • 4
  • 7
  • 21

2 Answers2

1

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" %> 
Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76
  • im not sure if i understand, but im sorry i wrote bad directory, i have my index.jsp at default directory, its in webapp/index.jsp, but i would like to have it in webapp/WEB-INF/index.jsp, but i can't setup my app to access this index page after starting the application – Charlie Harper Jul 02 '14 at 17:41
  • Why you want to place it inside the WEB-INF folder? – Braj Jul 02 '14 at 17:44
  • oh sry, i'm confused, i just came in... exactly, i would like to move it into WEB-INF/jsp/ folder, it looks more organised if there are all .jsp files together – Charlie Harper Jul 02 '14 at 17:47
  • Follow the link that I shared you in my post. That might help you. – Braj Jul 02 '14 at 17:47
  • i can't find the solution -.- – Charlie Harper Jul 02 '14 at 17:55
1

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

SparkOn
  • 8,806
  • 4
  • 29
  • 34