index.jsp default in Java EE project in Netbeans, where?

前端 未结 4 746
自闭症患者
自闭症患者 2020-12-30 09:42

I create a simple web application in Netbeans, named WebApplication1. There is a file created, named index.jsp. When I run the app, browser goes to index.

相关标签:
4条回答
  • 2020-12-30 10:24

    In Netbeans by default, if you create a project with no added frameworks, no deployment descriptor(web.xml) is provided. To change it, right click on the project and select New>Other>web>Standard Deployment Descriptor(web.xml)

    Now edit the web.xml and set

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

    In order to change the default to newjsp.jsp

    UPDATE

    Explicitly for tomcat....

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

    <!-- -->
    <!-- If you define welcome files in your own application's 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>
    

    That is why the index.jsp is shown by default

    0 讨论(0)
  • 2020-12-30 10:34

    Make sure the Jsp code file is not in Web-Inf directory, it should be in Web Pages directory.

    0 讨论(0)
  • 2020-12-30 10:38

    it could be index.html or index.jsp the welcome page of your web application in Netbeans.

    also there is a bug in Netbeans IDE 8.2 either : even if you make changes in the descriptor web.xml (by adding "welcome-file-list" tag), "Run" runs old version of your index!

    to fix this, put './index.html' in 'Relative URL' field in the category "Run" in properties of your project.

    0 讨论(0)
  • 2020-12-30 10:43

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

    ./nameOfYourJspFile.jsp
    

    and thats all, hope it helps!

    0 讨论(0)
提交回复
热议问题