Mike
Mike

Reputation: 3575

Redirect welcome page to a page in another domain in servlet container?

I tried

<welcome-file-list>
    <welcome-file>http://otherdomain.com/index.html</welcome-file>
</welcome-file-list>

but it does not work, also, i would like to redirect 404 error to a page in another domain too. Is it possible?

Upvotes: 0

Views: 2938

Answers (3)

Michele Mariotti
Michele Mariotti

Reputation: 7459

that's a strange requirement...

however:

index.jsp

<%@page language="java" contentType="text/html; charset=ISO-8859-1" trimDirectiveWhitespaces="true" %>
<% response.sendRedirect("http://www.stackoverflow.com"); %>

web.xml:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Upvotes: 0

Nidhish Krishnan
Nidhish Krishnan

Reputation: 20751

No you can't redirect welcome page to a page in another domain in different servlet container.

welcome-file-list
The optional welcome-file-list element contains an ordered list of welcome-file elements. When the URL request is a directory name, WebLogic Server serves the first file specified in this element. If that file is not found, the server then tries the next file in the list.

Upvotes: 0

dkaisers
dkaisers

Reputation: 844

I don't know if you can adress another domain directly. The tag is called "welcome-file", so URLs may not be possible. A workaround would be to create a welcome page and error page in the domain of the request and just redirect using HTML:

<head>
  <meta http-equiv="refresh" content="0; URL=http://otherdomain.com/index.html"/>
</head>

Content is the number of seconds to wait till the user is redirected.

Upvotes: 1

Related Questions