一、jsp代碼
String chart1URL = c.makeSession(request, "chart1");
<img src='<%=response.encodeURL("getchart.jsp?"+chart1URL)%>' usemap="#map1" border="0">
二、過濾器代碼
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
HttpServletResponse resp=(HttpServletResponse)response;
HttpSession session=req.getSession(true);
resp.setContentType("text/html");
resp.setCharacterEncoding("UTF-8");
PrintWriter out=resp.getWriter();
String request_uri=req.getRequestURI();
String ctxPath=req.getContextPath();
String uri=request_uri.substring(ctxPath.length());
if(uri.contains("Login.jsp")||uri.contains("Login")||uri.contains("getchart")||uri.contains(".png")||uri.contains(".jpg")||uri.contains(".css")||uri.contains(".js")||uri.contains("testchart.jsp")) {
chain.doFilter(request, response);
}else {
if(null !=session.getAttribute("user")) {
chain.doFilter(request, response);
}else {
out.println("您還沒有登錄,請先登錄!3秒后回到登錄頁面。");
resp.setHeader("refresh","3;url="+ctxPath+"/Login.jsp");
return;
}
}
}
三、問題
無過濾器,顯示正常,上了過濾器后網頁不出圖。
打破零回復...
登錄 慧都網發表評論