/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 *
 */
package com.xpn.xwiki.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * A simple action that redirects to the main page of the wiki. This is to allow users to enter a URL like
 * <code>http://localhost:8080/xwiki</code> and be redirected automatically to
 * <code>http://localhost:8080/xwiki/bin/view/Main/</code>.
 */
public class HomePageRedirectServlet extends HttpServlet
{
    /**
     * {@inheritDoc}
     */
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        String home = getInitParameter("homePage");
        if (home == null) {
            // TODO: we cannot use the XWiki API to determine the right URL, because this is a servlet and the core
            // is reachable mainly from Struts. Getting access to the core requires too much duplication, so for the
            // moment we're going the easy way: hardcoded values.
            home = "bin/view/Main/";
        }
        response.sendRedirect(home);
    }
}

@@ -1443,130 +1443,251 @@
  /**
-%0A     * %7B@inheritDoc%7D%0A     */%0A    @Override%0A    public void doGet(HttpServletRequest request, HttpServletResponse response
+ The address to use as a home page where the users are redirected. */%0A    private String home = %22bin/view/Main/%22;%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     * %0A     * @see javax.servlet.GenericServlet#init()%0A     */%0A    @Override%0A    public void init(
 ) th
@@ -1711,21 +1711,8 @@
 tion
-, IOException
 %0A   
@@ -1726,84 +1726,22 @@
     
-String home = getInitParameter(%22homePage%22);%0A        if (home == null) %7B%0A    
+super.init();%0A
     
@@ -1856,20 +1856,16 @@
         
- 
-   
 // is re
@@ -1969,20 +1969,16 @@
         
-  
-  
 // momen
@@ -2035,46 +2035,327 @@
     
-    home = %22bin/view/Main/%22;%0A    
+String homeParameter = getInitParameter(%22homePage%22);%0A        if (homeParameter != null) %7B%0A            this.home = homeParameter;%0A        %7D%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     */%0A    @Override%0A    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException%0A
     
-%7D
+%7B
 %0A   
@@ -2381,16 +2381,21 @@
 edirect(
+this.
 home);%0A 

Make the address the HomePageRedirectServlet uses configurable Improvement: Determine the right URL to use only on startup