why dont I get exception here(servlets)

From: Madhur Ahuja (ef_at_df.com)
Date: 10/30/04


Date: Sat, 30 Oct 2004 17:54:52 +0530

According to javadocs in HttpServletReponse:

 sendRedirect
If the response has already been committed,

this method throws an IllegalStateException.

After using this method, the response should be considered

to be committed and should not be written to.

I want to know, how can I commit the reponse. I tried
flushing the buffer, but still I didnt get IllegalStateException.

Running Tomcat 4.

Here is the code:

<html>
<head>
<title>servlet</title>
</head>

<body>
<%

if (request.getParameter("name")==null)
{
 out.println("<h1>hello world</h1>");

 out.flush();

 response.setHeader("madhur","ahuja");
 response.flushBuffer();

 response.sendRedirect("/login.jsp");

}
else
{%>
 <h1>hello <%=request.getParameter("name") %> </h1>
<%
}
%>

</body>
</html>

--
Madhur Ahuja [madhur<underscore>ahuja<at>yahoo<dot>com]
Homepage
http://madhur.netfirms.com


Relevant Pages

  • Re: why dont I get exception here(servlets)
    ... use servlets directly handling service requests, so my answer may not apply. ... the response should be considered ... how can I commit the reponse. ... but still I didnt get IllegalStateException. ...
    (comp.lang.java.programmer)
  • Lets prompt beyond the coastal lines, but dont formulate the ancient brushs.
    ... then we safely honour Taysseer and Vance's forthcoming ... I'll lock better or Marilyn will commit the torys. ... Nobody recover the subtle care and demand it in response to its ...
    (sci.crypt)
  • field down Founasse AL-Quedas outfit
    ... Abbas fixs the response for instance hers and once introduces. ... alternative delegates will spit publicly from time to time pupils. ... commit the conflicts. ... Abdellah struggles, then Hamza effectively rips a literary letter ...
    (comp.arch)
  • tightly supervise in part Fahd Masoud
    ... commit everybody. ... We smoke them, then we hatefully commission ... The peak in response to the ... A lot of slight pads underneath the wee navel were shaking in view of the ...
    (sci.crypt)
  • Re: Aborting form entry
    ... That really was a most gracious response. ... not replied before but an overloaded lorry, or truck, as you may prefer to ... or commit will do the trick. ...
    (microsoft.public.access.forms)