Illegal State Exception while redirecting

2003-12-18 Thread Kumar, Sumit
Hello,

I am including a jsp header in every jsp page as follows:

jsp:include page=ConnInclude_Authenticate.jsp flush=true /

In this header, I call a class that checks if the valid user objects exists
in session. Otherwise the class returns authentication as false. If the user
object donot exist I redirect to another web site using
response.sendRedirect. 

However I get illegal state Exception (java.lang.IllegalStateException
at
org.apache.coyote.tomcat4.CoyoteResponseFacade.sendRedirect(CoyoteResponseFa
cade.java:340) 

Any suggestions please.. 

 The page of header is as follows:

%
   boolean isAuthenticated =
AuthenticationManager.authenticate(request.getParameter(userId)==null?:r
equest.getParameter(userId),
 
request.getParameter(password)==null?:request.getParameter(password),s
ession);
   if(!isAuthenticated)
   {
   System.out.println(\n AUTHENTICATION FAILED);


response.sendRedirect(http://sgtwebdv/gm?format=Sogeti/testAuth/portalHead.
shtmlappId=1ul=/reports.jsp);
   return;
   }
% 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Illegal State Exception while redirecting

2003-12-18 Thread Bill Barker
The spec forbids an included page from changing the headers or the status
code (Section 8.3 of the 2.3 Servlet Spec, which is what TC 4.1 follows).
This means that it is illegal to call sendRedirect from an included page
(and doubly so from one with flush=true :).

Kumar, Sumit [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello,

 I am including a jsp header in every jsp page as follows:

 jsp:include page=ConnInclude_Authenticate.jsp flush=true /

 In this header, I call a class that checks if the valid user objects
exists
 in session. Otherwise the class returns authentication as false. If the
user
 object donot exist I redirect to another web site using
 response.sendRedirect.

 However I get illegal state Exception (java.lang.IllegalStateException
 at

org.apache.coyote.tomcat4.CoyoteResponseFacade.sendRedirect(CoyoteResponseFa
 cade.java:340)

 Any suggestions please..

  The page of header is as follows:

 %
boolean isAuthenticated =

AuthenticationManager.authenticate(request.getParameter(userId)==null?:r
 equest.getParameter(userId),


request.getParameter(password)==null?:request.getParameter(password),s
 ession);
if(!isAuthenticated)
{
System.out.println(\n AUTHENTICATION FAILED);



response.sendRedirect(http://sgtwebdv/gm?format=Sogeti/testAuth/portalHead.
 shtmlappId=1ul=/reports.jsp);
return;
}
 %




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]