1 Reply Latest reply on Feb 16, 2006 2:26 PM by j2ee_junkie

    IllegalStateException

    tzablock

      Here is my troubling issue:

      this is the source code:

      public class MovieSearchControllerServlet extends HttpServlet
      {
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
      {
      String option = request.getParameter("option");
      if(!request.isUserInRole("FSUser")
      && !request.isUserInRole("FSAdmin") && option.equals("delete"))
      {
      response.reset();
      RequestDispatcher view = request.getRequestDispatcher("/FSWise/loginerror.jsp");
      view.forward(request,response);
      }

      and after i access the resource i get:

      java.lang.IllegalStateException: Cannot forward after response has been committed
      pl.com.filmservice.web.MovieSearchControllerServlet.doGet(MovieSearchControllerServlet.java:96)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

      why is that?

        • 1. Re: IllegalStateException
          j2ee_junkie

          tzablock,

          The Java 2 Platform EE API javadocs for reset() method explicitly state that reset() may throw this exception and why. So I guess your real question is why has the response been commited? Do you have any filters or other servlets that excute before this one?

          cgriffith