why dont I get exception here(servlets)
From: Madhur Ahuja (ef_at_df.com)
Date: 10/30/04
- Next message: Gareth McCaughan: "Re: Challenge: Triangles puzzle"
- Previous message: Alex Hunsley: "Re: [OT] Homework - Was Re: java programe help"
- Next in thread: shakahshakah_at_gmail.com: "Re: why dont I get exception here(servlets)"
- Reply: shakahshakah_at_gmail.com: "Re: why dont I get exception here(servlets)"
- Reply: marcus: "Re: why dont I get exception here(servlets)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Gareth McCaughan: "Re: Challenge: Triangles puzzle"
- Previous message: Alex Hunsley: "Re: [OT] Homework - Was Re: java programe help"
- Next in thread: shakahshakah_at_gmail.com: "Re: why dont I get exception here(servlets)"
- Reply: shakahshakah_at_gmail.com: "Re: why dont I get exception here(servlets)"
- Reply: marcus: "Re: why dont I get exception here(servlets)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|