开发者

JSP how to manage welcome-file-list?

开发者 https://www.devze.com 2023-02-07 07:17 出处:网络
How can i redirect users to one of the pages accordingly his domain name? web.xml <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-fi开发者_如何转开发le>
    <welcome-file>now_see_this.jsp</welcome-file>
    <welcome-file>Another.jsp</welcome-file>
</welcome-file-list>

Thanks!!!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消