0

I want to redirect to the logOut url in filter,when some condition occurs.

I tried sendRedirect and forward method of requestDispatcher...but getting this error. I have commented the sendredirect Code.

if(){
    res.setHeader("fsd", "FAILURE");
    res.sendError(HttpServletResponse.SC_FORBIDDEN);
    /*res.sendRedirect("/searchReleaseLockLogout");*/                    
    req.getRequestDispatcher("/searchReleaseLockLogout").forward(req, res);
    return;
}
Vivek Singh
  • 2,047
  • 11
  • 24
bisnu
  • 1
  • 2

1 Answers1

0

When invoke sendError on response, the response is already committed. Check documentation here.Use setStatus instead.

Change,

 res.sendError(HttpServletResponse.SC_FORBIDDEN);

to

 res.setStatus(HttpServletResponse.SC_FORBIDDEN);
Adisesha
  • 5,200
  • 1
  • 32
  • 43