eclipse dynamic web project - default start page

Viewed 60800

I created in Eclipse dynamic web project, I have index.html in WEB-INF folder. I click on the main folder of the project Run as > Run on server chose Tomcat v7.0, finish, and it runs OK. But, when I rename index.html to another name I get the message:

The requested resource (/MyProject/) is not available.

  1. How can I change the default page ?
  2. can I put in default page asp file ?

My web.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>MyFirstServlet</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description>new</description>
    <display-name>GrettingServlet</display-name>
    <servlet-name>GrettingServlet</servlet-name>
    <servlet-class>GrettingServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>GrettingServlet</servlet-name>
    <url-pattern>/GrettingServlet</url-pattern>
  </servlet-mapping>
</web-app>
5 Answers

this also happens when there is a 404 error, Tomcat searches by default for the index file. jsp/html , you must change it from the Tomcat folder in the web.xml file.inside of Tomcat Eclipse or in installed folder system(c/files Program/apache...) o look at this example

Open Eclipse-> click on servers-> choose Tomcat v9.0 Server at localhost-config-> select "web.xml"-> scroll to the bottom or find " "-> "filename.xml"

image

Related