简体   繁体   中英

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!!!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM