Jama A.
Jama A.

Reputation: 16079

JSP how to manage welcome-file-list?

How can i redirect users to one of the pages accordingly his domain name?
web.xml

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

Thanks!!!

Upvotes: 0

Views: 1687

Answers (1)

Bozho
Bozho

Reputation: 597076

You can

  • make a filter (javax.servlet.Filter)
  • map it to /
  • check request.getServerName() and compare with a predefined list of domains
  • request.getRequestDispatcher("/someIndex.jsp").forward() depending on the domain.

However, it looks like a strange use-case, because the user will still be able to access the index files for other domains if he knows them (if they are not hidden in WEB-INF). But without knowing your requirements I can't suggest a better solution.

Upvotes: 2

Related Questions