मैं एक ही समस्या ... था, लेकिन मैं स्पष्ट कारणों के लिए कंटेनर से बंधा कोड writting पसंद नहीं है ।
तो मैंने सत्र में अपवाद जोड़ने के लिए क्या किया था। साथ HttpSession को
अपवाद
catch (Exception e) { // or just catch LoginException
log.log(Level.SEVERE, e.getMessage(), e);
SecurityThreadLocal.setException(e);
}
जोड़ें:
सबसे पहले, एक ThreadLocal अपवाद धारक का निर्माण LoginContext और ServletContext के बीच अपवाद भेजने के लिए:
public final class SecurityThreadLocal {
private static final ThreadLocal<Exception> j_exception = new ThreadLocal<Exception>();
public static void setException(Exception e) {
j_exception.set(e);
}
public static Exception getException() {
return (Exception)j_exception.get();
}
public static void clear() {
j_exception.remove();
}
}
SecurityThreadLocal को LoginException जोड़े एक फ़िल्टर:
web.xml
<filter-mapping>
<filter-name>SecurityFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
SecurityFilter.java
if (uri.endsWith("<form-error-page>") && session != null){
Exception j_exception = SecurityThreadLocal.getException();
if(j_exception != null)
session.setAttribute("j_exception", j_exception);
}
लेकिन जैसे-जैसे मैं जानता हूँ कि यह एक बुरा व्यवहार और एक सुरक्षा दरार है आपको पता होना चाहिए।
अच्छा .., मेरे मामले में ग्राहक जीता ...
स्रोत
2016-07-15 15:50:57