| Author |
about sendRedirect
|
mohamed ewis
Greenhorn
Joined: Feb 05, 2006
Posts: 18
|
|
sendredirect : i know taht We cannot call this method if the response is committed�that is,if the response header has already been sent to the browser but when i write it after commiting response no exception thrown ,why PrintWriter out = response.getWriter(); try { out.println("<html>"); out.println("<head>"); out.println("<title>NewServlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>NewServlet at " + request.getContextPath () + "</h1>"); out.println("</body>"); out.println("</html>"); response.sendRedirect("http://www.cnn.com");
|
 |
Abi Ted
Greenhorn
Joined: May 24, 2008
Posts: 13
|
|
the response buffer is just filled.... it is not committed.... or out.flush() not called yet...
|
 |
mohamed ewis
Greenhorn
Joined: Feb 05, 2006
Posts: 18
|
|
thanks Abinesh for your reply manuly flush response and still no exception PrintWriter out = response.getWriter(); try { out.println("<html>"); out.println("<head>"); out.println("<title>NewServlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>NewServlet at " + request.getContextPath () + "</h1>"); out.println("</body>"); out.println("</html>"); out.flush(); // flush response response.sendRedirect("http://www.cnn.com");
|
 |
Abi Ted
Greenhorn
Joined: May 24, 2008
Posts: 13
|
|
i see a try{ in your program... what exception are you handling?? because some programmers handle it this way... try{ }catch(Exception e){} This is wrong... Please post the catch also...
|
 |
Amol Fuke
Ranch Hand
Joined: Apr 08, 2005
Posts: 129
|
|
I tried this : and it throws exception on console. Thanks, Amol
|
"There are no mistakes, only lessons"
|
 |
mohamed ewis
Greenhorn
Joined: Feb 05, 2006
Posts: 18
|
|
hi amol ,thanks for reply i tried the code as you wrote and no exceptions thrown , it out NewServlet at /JSPStudy in browser window
|
 |
 |
|
|
subject: about sendRedirect
|
|
|