Redirect from ROOT

I am trying to redirect to the welcome page from ROOT. When www.mydomain.com is called from a browser, the servlet inside ROOT should redirect to another web page in webapps/welcome/index.jsp

What I did:

com.index.Redirect

publicclass Redirectextends HttpServlet

{

privatefinal String url ="welcome/index.jsp";

publicvoid doGet(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException

{

response.sendRedirect(url);

}

}

web.xml:

<servlet>

<servlet-name>Index</servlet-name>

<servlet-class>com.index.Redirect</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Index</servlet-name>

<url-pattern>/index</url-pattern>

</servlet-mapping>

What I got: The requested resource (/) is not available

What am I missing? Thanks

[1366 byte] By [Rusty_Shackleforda] at [2007-11-26 13:48:51]
# 1

"/" is not the same as "/index". The mapping from / to /index is done on the server side, not the client, so you can't assume that every hit will start with at least /index. Also if I recall correctly / has a special meaning in servlet environment configurations and may not behave as expected.

Generally (or always?) web servers and I believe servlet containers have a special configuration option to identify a home page, so be careful that you're not reinventing the wheel here.

paulcwa at 2007-7-8 1:25:04 > top of Java-index,Java Essentials,Java Programming...