try { String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort(); User user = UserLocalServiceUtil.getUserById(uid); String type = user.getIdentityid(); if("TEA".equals(type)){ response.sendRedirect(basePath+"/web/teacher/default"); }else if("STU".equals(type)){ response.sendRedirect(basePath+"/web/student/index"); }else{ response.sendRedirect(basePath+"/web/guest/admin"); } } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); }