Ho alcuni pezzi di html contenuti in una cartella che includo di volta in volta nelle pagine jsp. Per impedire tali file singolarmente è corretto creare a monte un filtro aggiuntivo che rimandi l'utente alla index ogni volta che il client tenti di visualizzare questi spezzoni di html?
codice:if (request instanceof HttpServletRequest & response instanceof HttpServletResponse) { HttpServletRequest httpReq = (HttpServletRequest) request; HttpServletResponse httpRes = (HttpServletResponse) response; if (testURL(httpReq)) { try { chain.doFilter(httpReq, httpRes); } catch (Exception ex) { ex.printStackTrace(); } } else { httpRes.sendRedirect("/index.jsp#home"); } }Il codice l'ho già testato e non funziona.codice:private static boolean testURL(HttpServletRequest httpReq) { String a = httpReq.getRequestURI(); String b = a.substring(0,8); String c = "/blocchi/"; System.out.println(b); return (b.equals(c)) ? false : true; }
ciao

Rispondi quotando