• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about sendRedirect

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the response buffer is just filled.... it is not committed....

or out.flush() not called yet...
 
mohamed ewis
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this :


and it throws exception on console.

Thanks,
Amol
 
mohamed ewis
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi amol ,thanks for reply
i tried the code as you wrote and no exceptions thrown ,
it out NewServlet at /JSPStudy in browser window
 
reply
    Bookmark Topic Watch Topic
  • New Topic