Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:45:53+00:00 2026-06-10T02:45:53+00:00

I Have problem When redirect to jsp . I Have put my servlet code

  • 0

I Have problem When redirect to jsp . I Have put my servlet code below. and also I have put error log. Can any one please help me to fix the problem. If you need further details pl comment it below. I Have done samething in other servlet It is working .

  public class DoctorServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String sDocId=request.getParameter("doctorId");
        Integer dId=Integer.parseInt(sDocId);
        String speciality=request.getParameter("speciality");
        String experience=request.getParameter("experience");
        String qualification=request.getParameter("qualification");
        String sempId=request.getParameter("employeeId");
        Integer empId=Integer.parseInt(sempId);
        String action=request.getParameter("method");

        Doctors d=new Doctors();

        if(action.equalsIgnoreCase("add")){

            d.setDocId(dId);
            d.setEmpId(empId);
            d.setExp(experience);
            d.setSumOfQn(qualification);
            d.setSpeciality(speciality);
            try {
                boolean result=new Doctors().insertDoctor(d);
                if(result==true){

                    request.setAttribute("add","sucess");
                }
                  request.getRequestDispatcher("doctor_result.jsp").forward(request, response);
                response.sendRedirect("doctor_result.jsp");


            } catch (SQLException ex) {
                Logger.getLogger(DoctorServlet.class.getName()).log(Level.SEVERE, null, ex);
            }

        }


    }


}

    Aug 23, 2012 12:29:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [DoctorServlet] in context with path [/AsiaHospital] threw exception
java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
    at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:483)
    at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:138)
    at com.asiahospital.servlet.DoctorServlet.doPost(DoctorServlet.java:52)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:45:54+00:00Added an answer on June 10, 2026 at 2:45 am

    You are forwarding to some other JSP so it commits the response

    request.getRequestDispatcher("doctor_result.jsp").forward(request, response);
    

    now you are trying to send the response back which is already committed

    response.sendRedirect("doctor_result.jsp");
    

    which is invalid

    You should either forward or redirect the same response instance


    See Also

    • difference between forwarding and redirection
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I experience strange problem. We have error handling in global.asax that would redirect user
I want to redirect JSP page from one servlet. All JSP pages are under
I have a javax.servlet.Filter class that I would like to redirect urls. The problem
I have a problem with php header redirect. I already spent hours trying to
I have a problem with validation messages not showing after a redirect, even when
In my web.xml page I have the 404 error mapped to a jsp page
I have a problem with a redirect I am trying to do from within
I have a slight problem with .htaccess redirect. I have a dynamic site with
Here is a problem I have encountered. I have jsp page which has a
I have a problem where I need to redirect 4 specific pages on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.