How to disable Tomcat home page

后端 未结 8 518
自闭症患者
自闭症患者 2020-12-28 16:51

I deployed my application in Tomcat and the application path is:

http://localhost:8080/myapp

but I want to restrict my users to not see To

相关标签:
8条回答
  • 2020-12-28 17:08

    rename the ROOT app to another folder name (or delete it if you don't want to manage tomcat with the tomcat manager app)

    Put the app you want to see at http://localhost:8080 in the ROOT folder

    0 讨论(0)
  • 2020-12-28 17:08

    Upload ROOT.war with some other content or alternatively try to remove the folder ROOT/ from webapps

    0 讨论(0)
  • 2020-12-28 17:09

    I think the author of the question asked specifically about disabling Tomcat home page, not redirecting it. I found helpful tip on ibm website. I tried it and it worked for me. Here are steps:

    1. Go to Apache Tomcat conf directory
    2. Edit the web.xml file content. Comment out following lines:
    
        <!--
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        -->
    

    IBM reference web page: Disabling the Apache Tomcat default home page on ...

    0 讨论(0)
  • 2020-12-28 17:15

    I just discovered that you can connect as manager when the application is in production and stop the welcoming page.

    And if someone try to access again the welcoming page (http://localhost:8080), it will not work:

    0 讨论(0)
  • 2020-12-28 17:19

    refer How to Change Default Homepage in Tomcat

    EDIT:

    link is broked so you can try following:

    The easiest would be to have the Tomcat home page (TOMCAT_HOME/webapps/ROOT/index.jsp) perform a redirect to your start page.

    Or, if you have just a single web app, you can move that to the ROOT web app.

    0 讨论(0)
  • 2020-12-28 17:19

    You might think changing the jsp page at $CATALINA_HOME/webapps/ROOT/index.jsp is all you need to do. This is where I found out it's not the case! The page contents are compiled within the ROOT web application servlet. To make Tomcat reference the jsp page instead, we need to prevent this servlet from being compiled.

    Locate the ROOT web application’s config file at $CATALINA_HOME/webapps/ROOT/WEB-INF/web.xml, and simply comment out the following code fragment:

    <!-- Comment this section so I can change the default index.jsp homepage
    <servlet>
      <servlet-name>org.apache.jsp.index_jsp</servlet-name>
      <servlet-class>org.apache.jsp.index_jsp</servlet-class>
    </servlet>
    
    <servlet-mapping>
      <servlet-name>org.apache.jsp.index_jsp</servlet-name>
      <url-pattern>/index.jsp</url-pattern>
    </servlet-mapping>
    -->
    

    This will disable the index_jsp servlet. Now when you restart the Tomcat web application server, it should compile and load the default $CATALINA_HOME/webapps/ROOT/index.jsp page instead.

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