tomat root 目录下的index.jsp
<%@ page import="org.apache.regexp.RE"%>
<%@ page import="org.apache.regexp.RESyntaxException"%>
<%
String requestURL = request.getRequestURL().toString();
String requestURI = request.getRequestURI();
String contentPath= request.getContextPath();
System.out.println("contentPath:"+contentPath);
//System.out.println( ">>> requestURI="+requestURI );
RE REmloveRef=null;
try {
REmloveRef = new RE("^http://[A-Za-z0-9]*.blog.my3city.cn", RE.MATCH_CASEINDEPENDENT);
//REmloveRef = new RE("^http://[A-Za-z0-9]*.blog.andylau.com", RE.MATCH_CASEINDEPENDENT);
} catch (RESyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// for andylau
//*.blog.andylau.com
// System.out.prinln(">>>>REmloveRef.match(requestURL):"+REmloveRef.match(requestURL));
if(REmloveRef!=null&&REmloveRef.match(requestURL))
{
String uid="";
String tmp=requestURL.substring(7);
int pot=tmp.indexOf(".");
if(pot>0)
{
uid=tmp.substring(0,pot);
//System.out.println(">>>>the uid:"+uid);
//System.out.println("/andylau/andylau/blog/personMain.do?ownerId="+uid);
}
response.sendRedirect("/andylau/andylau/blog/personMain.do?ownerId="+uid);
}else{
response.sendRedirect("/andylau/index.do");
}
//if ( requestURL.startsWith("http://www") ) {
// response.sendRedirect("/andylau/index.do");
// } else {
// response.sendRedirect("/andylau/myhome/index.do");
// }
%>