Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a sub-folder as web.xml welcome directory

I want to configure my web.xml for Google App Engine, but my configuration doesn't work. I want to change the default index.html with WebApp/index.html.

Here is the web.xml:

<servlet>
    <servlet-name>App</servlet-name>
    <servlet-class>bg.app.AppServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>App</servlet-name>
    <url-pattern>/WebApp/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>WebApp/index.html</welcome-file>
</welcome-file-list>
like image 906
uccie Avatar asked May 07 '13 17:05

uccie


People also ask

In which folder we can put WEB XML?

The deployment descriptor is a file named web. xml . It resides in the app's WAR under the WEB-INF/ directory.

How do I map a JSP page in WEB XML?

jsp . If you want more control over how the JSP is mapped to a URL, you can specify the mapping explicitly by declaring it with a <servlet> element in the deployment descriptor. Instead of a <servlet-class> element, you specify a <jsp-file> element with the path to the JSP file from the WAR root.

What file specifies the default welcome page?

If no welcome file is specified, the Application Server will use a file named index. XXX , where XXX can be html or jsp, as the default welcome file.

Which option in WEB XML will load the HTML page when the project is started?

The tag <welcome-file-list> is used for specifying the files that needs to be invoked by server by default, if you do not specify a file name while loading the project on browser. Based on the welcome file list, server would look for the myhome.


1 Answers

The "welcome file" represents the physical file which needs to be served when a folder is requested by URL. E.g. / or /WebApp/ or WebApp/foo/. It does not represent the "homepage file" or so as many starters seem to think. It does not make sense to let the welcome file point to a subfolder. It would fail when another subfolder is been requested.

Just stick to index.html as welcome file, put the desired homepage file in /WebApp/ folder and create another index.html file in root folder / with the following content:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Dummy homepage</title>
    <meta http-equiv="refresh" content="0; url=WebApp" />
  </head>
</html>

This will redirect to /WebApp/ (searchbots will treat it as 301) which in turn should serve the desired homepage file.

See also:

  • How to configure welcome file list in web.xml
  • Set default home page via <welcome-file> in JSF project
  • Change default homepage in root path to servlet with doGet
like image 198
BalusC Avatar answered Oct 09 '22 14:10

BalusC