<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String ip=request.getRemoteAddr();
Cookie cookie[]=request.getCookies();
String username="";
if(cookie!=null && cookie.length>0){
for(int i=0; i<cookie.length; i++){
if("username".equals(cookie[i].getName())){
username=cookie[i].getValue();
break;
}
}
}
%>
request.getContextPath()獲取項目名稱;
request.getSchema()可以返回當前頁面使用的協議,http 或是 https;
request.getServerName()可以返回當前頁面所在的服務器的名字;
request.getServerPort()可以返回當前頁面所在的服務器使用的端口,默認80;
request.getRemoteAddr()獲取ip,比如本地的127.0.0.1
request.getCookies()獲取網站客戶的的緩存