-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jonathan,
Jonathan O'Donovan wrote: | Am I right in saying the following? : | | 1) These are the the most important entries in the stack trace | | ----- Root Cause ----- | java.lang.IllegalStateException | at org.apache.coyote.tomcat4.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:290) | at org.apache.jsp.login_jsp._jspService(login_jsp.java:102) Yes. | 2) These are the lines from login_jsp.java taken from the /work | directory in Tomcat | | 101> if(sessionNew) { | 102> response.sendRedirect(url_userServletMain); | 103> } | | So there is a problem with sendRedirect or the parameter | url_userServletMain Now so much a problem with the method or the parameter, but a problem with the status of the response (see below). | 3) Can anyone tell me if these lines are important or not? | | at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:298) | at my.domain.opentools.ServPublicAreaController.gotoPage(ServPublicAreaController.java:686) | at my.domain.opentools.ServPublicAreaController.doLogin(ServPublicAreaController.java:177) | at my.domain.opentools.ServPublicAreaController.service(ServPublicAreaController.java:103) Not so much. These lines indicate that the request was processed by your ServPublicAreaController servlet and then forwarded-on to another servlet (which looks like a compiled JSP). There is no exception message (which is weird) but I would expect that the IllegalStateException is occurring because your JSP generated some output (to the response) and then you tried to send a redirect, which is a response header. That is not always a big deal, but the response is usually buffered, and that buffer has a finite size. Once you exceed the size of the buffer, the response is sent to the client, starting with the headers. Once the headers have been sent, you can't un-send them and add more headers. Thus, you get an IllegalStateException because you have asked the servlet container to sent a redirect (which is done via a response header) but the headers have already been sent. There are a couple of ways to fix this. 1. Increase the size of the response buffer. I don't favor this technique because it's sort of a hack. You're basically giving up on good design and allowing your code to be sloppy because, hey, you can always wipe-out the buffer and re-write the response. :( 2. Inspect your JSP to see where you are generating content for the response. Anything that is not within <jsp:> or <@ ...> tags is generating response data -- particularly whitespace. So, if you have a lot of JSP tags on separate lines, then you're sending a whole bunch of newlines to the response without even realizing it. Another thing you might want to do is re-evaluate where you perform this redirect. Often, redirect logic is performed towards the /end/ of a servlet (or JSP, in this case). At the end of the JSP is where the most content has already been generated, and where you are most likely to find yourself in this situation. Consider moving the redirect towards the top of the JSP. 3. Consider switching to a servlet instead of a JSP. JSPs are typically used for output -- to generate content. Why are you using a JSP if you aren't sure you are going to be generating content? I have seen reasons to use redirects in JSPs, but those situations are generally pretty rare. Are you sure this decision (to redirect) wouldn't be better made in some other place in the code? Hope that helps, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkgQvB0ACgkQ9CaO5/Lv0PBYUwCcCCMyZ37px1SW+TeOz343u/XM YKEAoIav3Vu4fqYJ56gsGaeBFiLP/q3w =p36Q -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]