在我的应用程序中,用户可以订阅不同的俱乐部,例如儿童俱乐部、青年俱乐部、成人俱乐部和老年俱乐部。现在,假设如果用户已经在 2012 年 10 月 7 日订阅了儿童俱乐部,并且如果他在 2012 年 11 月 2 日再次尝试订阅同一个俱乐部“儿童俱乐部”,那么我们尝试将该用户重定向到另一个俱乐部,例如青年俱乐部或成人俱乐部或老年俱乐部。每个俱乐部都有自己的域名,例如(例如)
Kid club = kidclub.google.mobi
Youth Club = youthclub.yahoo.mobi
Adult Club=adult.godaddy.mobi
Elderly Club = elderly.google.mobi
以下是重定向的示例代码,但这不是重定向到不同的域 URL。是sendRedirect()方法的原因吗?这个应用程序中没有使用Servlet。Apache Tomcat 服务器中的 MySQL 数据库仅使用 JSP 请尽快提出建议。
void doRedirect(HttpServletResponse response, String url)
{
try
{
response.sendRedirect(url);
}
catch (Exception e)
{
e.printStackTrace()
}
}
void redirectReturningUser( HttpServletRequest request, HttpServletResponse
response, ClubDomain currentDomain )
{
String redirectToUrl = currentDomain.getDefaultUrl();
if( "kidclub.google.mobi".equals( currentDomain.getDefaultUrl() ) )
redirectToUrl = "youthclub.yahoo.mobi";
else if( "adult.godaddy.mobi".equals( currentDomain.getDefaultUrl() ) )
redirectToUrl = "kidclub.google.mobi";
else if( "youthclub.yahoo.mobi".equals( currentDomain.getDefaultUrl() ) )
redirectToUrl = "adult.godaddy.mobi";
else if( "adult.godaddy.mobi".equals( currentDomain.getDefaultUrl() ) )
redirectToUrl = "elderly.google.mobi";
else if( "elderly.google.mobi".equals( currentDomain.getDefaultUrl() ) )
redirectToUrl = "adult.godaddy.mobi";
doRedirect(response, "http://"+redirectToUrl );
}
提前致谢