Index.jsp by default in a Java EE project in Netbeans, where?

I am creating a simple web application in Netbeans called WebApplication1. A file named index.jsp . When I launch the application, the browser goes to index.jsp . Nowhere in the project is it mentioned as a welcome page, then how does this happen? I checked build.xml, glassfish-web.xml and all the xml, prop files in the nbproject folder, but index.jsp is not mentioned index.jsp . How does this happen?

+7
source share
4 answers

In Netbeans, by default, when creating a project without added frameworks, a deployment descriptor (web.xml) is not provided. To change it, right-click on the project and select New>Other>web>Standard Deployment Descriptor(web.xml)

Now edit the web.xml file and install

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

To change the default value to newjsp.jsp

UPDATE

Explicitly for tomcat ....

If web.xml is not specified in the application, the default web.xml ($ CATALINA_HOME / conf / web.xml) Tomcat is provided to the application. This deployment descriptor has the following lines:

 <!-- --> <!-- If you define welcome files in your own application web.xml --> <!-- deployment descriptor, that list *replaces* the list configured --> <!-- here, so be sure to include any of the default values that you wish --> <!-- to use within your application. --> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> 

This is why index.jsp is displayed by default

+14
source

If you are using netBeans, you need to click the right button on your project and then properties. A new pop-up window will open, and in the left menu a call to the label will be performed. Click here and then in the "relative URL" you should put

 ./nameOfYourJspFile.jsp 

and that’s all, I hope this helps!

+4
source

Make sure the Jsp code is not in the Web-Inf directory, it must be in the web pages directory.

+1
source

it can be index.html or index.jsp

there is also a bug in NetbeansIDE 8.2: even if you make changes to the web.xml descriptor (by adding), "Launch" launches the old version of your index!

to fix this, I confirm, put "./index.html" in the "Relative URL" field in the "Run" category in your project properties, thanks "SomeAnonymousPerson"

0
source

All Articles