Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJWCD
Search Coderanch
Advance search
Google search
Register / Login
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:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Web Component Certification (OCEJWCD)
about sendRedirect
mohamed ewis
Greenhorn
Posts: 18
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 13
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the response buffer is just filled.... it is not committed....
or out.flush() not called yet...
mohamed ewis
Greenhorn
Posts: 18
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 129
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I tried this :
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"); }catch(Exception ex) { ex.printStackTrace();d }
and it throws exception on console.
Thanks,
Amol
"There are no mistakes, only lessons"
mohamed ewis
Greenhorn
Posts: 18
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
response.SendRedirect and session
New to servlets
How to test my servlet
tomcat return an error +mvc
Confused with flush() behavior
More...