• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

request & response

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In HFSJ,pg#137 it said that "you can't do a sendRedirect() after writing to the response"

but when i run code1 the following code in servlet it gave no error & done the redirect

code1:
-------------------------------------------------------------------------
PrintWriter out = res.getWriter();
String name=req.getParameter("param1");
String client=req.getHeader("User-Agent");
out.println("<html>"+"<body>"+client+"venu Navat"+"</html>"+"</body>");
res.sendRedirect("http://www.google.com");
-------------------------------------------------------------------------

when i run code2 in servlet it gave no error & displayed response & didn't redirect

code2:
-------------------------------------------------------------------------
PrintWriter out = res.getWriter();
String name=req.getParameter("param1");
String client=req.getHeader("User-Agent");
out.println("<html>"+"<body>"+client+"venu Navat"+"</html>"+"</body>");
out.flush();
res.sendRedirect("http://www.google.com");
-------------------------------------------------------------------------

please clarify !!
 
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The details of exception are visible in log files.
Check them
 
navat venu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I checked the log files!
And you are true, i could see the "IllegalStaeException" for code2 in log file.

Thanks shivani!!
 
It is difficult to free fools from the chains they revere - Voltaire. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic