response.sendredirect and IllegalStateException
Hi, I was using tomcat 3.1 for one of my client sites. Currently they gonna update it to the latest. When I ported by the application into tomcat 5.5, I found that response.SendRedirect is giving me the error which was due to the calling the some action after calling the SendRedirect. But since it's working in 3.1, do we've any setting in 5.5 which can bypass this check ? Otherwise I'll have to rewrite all my jsp pages. Regards Abhi
page not loading completely with tomcat and response.sendRedirect()
We are using response.sendRedirect() to refresh a jsp page by redirecting to itself. When the page is redirected to itself, a portion of the static html code is not completely loaded. Below is the portion of the html code. If we remove 5 lines of code eg: some option values.the page loads completely and everything works properly! We suspect that there is some sort of buffer/memory issue with Tomcat. Please help, have tried on 2 versions of tomcat: 4.1.31 and 5.5.7 on redhat fedora core 3. td SELECT name=myLine OPTION SELECTED value=% out.println(jMyLine); % % out.println(jMyLine); % OPTION value=UnknownUnknown OPTION value=00 OPTION value=55 OPTION value=1010 OPTION value=1515 OPTION value=2020 OPTION value=2525 OPTION value=3030 OPTION value=4040 OPTION value=5050 OPTION value=6060 OPTION value=7070 OPTION value=8080 OPTION value=9090 OPTION value=100100 OPTION value=125125 OPTION value=150150 OPTION value=175175 OPTION value=200200 OPTION value=225225 OPTION value=250250 OPTION value=275275 OPTION value=300300 OPTION value=350350 OPTION value=400400 OPTION value=450450 /SELECT /td td input type=submit value=%out.println(submitButtonName); % name=mySubmit /font /td td input type=submit value=% out.println(clearButtonName); % name=reset/font /td Thanks, Kris
Re: response.sendRedirect()
Sorry, I did more test about the problem. I have one JSP(jspa) and (jspb) from jsp I do an include of jspb and from jspb I have a sendRedirect(www.google.com). If I invoke to http:///../jspa.jsp it doesn't work, but If I invoke directly to http://..//jspb.jsp It works ok. best regard Ben Souther ([EMAIL PROTECTED]) escribi? Without seeing the rest of your code, I'll guess that the problem is that you've started the relative link with a /. Try without it. If you have to back up a directory use ../jknopkn/prueba.jsp. On Wed, 2004-10-06 at 11:11, Pablo Carretero Sánchez wrote: Hi, I don't test in other Tomcat version. I'm trying a sendRedirect() in one JSP. And it doesn't work. The code is: response.sendRediredt(/jknopkn/prueba.jsp); QM ([EMAIL PROTECTED]) escribió: On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velazquez nº 3 Esc Izq 7º B 28932 #8211; Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Are you getting any error messages in your log files? In your browser window? It sounds like your trying to call sendRedirect after you've already started sending output to the browser. Try moving the include to the very top of the jspa page. On Thu, 2004-10-07 at 03:04, Pablo Carretero Snchez wrote: Sorry, I did more test about the problem. I have one JSP(jspa) and (jspb) from jsp I do an include of jspb and from jspb I have a sendRedirect(www.google.com). If I invoke to http:///../jspa.jsp it doesn't work, but If I invoke directly to http://..//jspb.jsp It works ok. best regard Ben Souther ([EMAIL PROTECTED]) escribi? Without seeing the rest of your code, I'll guess that the problem is that you've started the relative link with a /. Try without it. If you have to back up a directory use ../jknopkn/prueba.jsp. On Wed, 2004-10-06 at 11:11, Pablo Carretero Snchez wrote: Hi, I don't test in other Tomcat version. I'm trying a sendRedirect() in one JSP. And it doesn't work. The code is: response.sendRediredt(/jknopkn/prueba.jsp); QM ([EMAIL PROTECTED]) escribi: On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect()
Hi, I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. It doesn't work in my appl. Can anyone help me. Thanks a lot -- __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velazquez nº 3 Esc Izq 7º B 28932 #8211; Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Hi, I don't test in other Tomcat version. I'm trying a sendRedirect() in one JSP. And it doesn't work. The code is: response.sendRediredt(/jknopkn/prueba.jsp); QM ([EMAIL PROTECTED]) escribió: On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velazquez nº 3 Esc Izq 7º B 28932 #8211; Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect()
You haven't answered the main question, which is, exactly what doesn't work? Is there an error? Is the redirect ignored? Anything else? If it is in a JSP, have you enclosed the redirect in % %? I also assume you have spelt it correctly in the code as there is a spelling mistake in your example below. Ta Matt -Original Message- From: Pablo Carretero Sánchez [mailto:[EMAIL PROTECTED] Sent: 06 October 2004 16:11 To: Tomcat Users List Subject: Re: response.sendRedirect() Hi, I don't test in other Tomcat version. I'm trying a sendRedirect() in one JSP. And it doesn't work. The code is: response.sendRediredt(/jknopkn/prueba.jsp); QM ([EMAIL PROTECTED]) escribió: On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velazquez nº 3 Esc Izq 7º B 28932 #8211; Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Any opinions expressed in this E-mail may be those of the individual and not necessarily the company. This E-mail and any files transmitted with it are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that you have received this E-mail in error and that any use or copying is strictly prohibited. If you have received this E-mail in error please notify the beCogent postmaster at [EMAIL PROTECTED] Unless expressly stated, opinions in this email are those of the individual sender and not beCogent Ltd. You must take full responsibility for virus checking this email and any attachments. Please note that the content of this email or any of its attachments may contain data that falls within the scope of the Data Protection Acts and that you must ensure that any handling or processing of such data by you is fully compliant with the terms and provisions of the Data Protection Act 1984 and 1998. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect()
works for me -Original Message- From: Pablo Carretero Sánchez [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 06, 2004 9:39 AM To: [EMAIL PROTECTED] Subject: response.sendRedirect() Hi, I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. It doesn't work in my appl. Can anyone help me. Thanks a lot -- __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velazquez nº 3 Esc Izq 7º B 28932 #8211; Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 9/22/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 9/22/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Without seeing the rest of your code, I'll guess that the problem is that you've started the relative link with a /. Try without it. If you have to back up a directory use ../jknopkn/prueba.jsp. On Wed, 2004-10-06 at 11:11, Pablo Carretero Snchez wrote: Hi, I don't test in other Tomcat version. I'm trying a sendRedirect() in one JSP. And it doesn't work. The code is: response.sendRediredt(/jknopkn/prueba.jsp); QM ([EMAIL PROTECTED]) escribi: On Wed, Oct 06, 2004 at 04:38:54PM +0200, Pablo Carretero S?nchez wrote: : I have a urgent problem response.sendRedirect() in Tomcat 5.0.27. : : It doesn't work in my appl. What, specifically, doesn't work? Did this same code work in a previous version of Tomcat 5.0.x? etc, etc. We're all pretty sharp here, but I don't think any of us are clairvoyant. ;) -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendredirect failig from an included .jsp
Tim, Thanks for the info. The redirect that I'm trying to achieve is actually internal to my site. So I started looking at requestdispatcher.forward( ), but it appears to me that you have to simply pass the same 'request' and 'response' variables into it. I need to be able to clear the variables in the query string. Any ideas? Thanks, Jon On Tue, 03 Aug 2004 19:50:11 -0400, Tim Funk [EMAIL PROTECTED] wrote: Yes it should be failing. You cannot set headers or issue redirects from an include. (Its a rule in the spec) -Tim Jon Beyer wrote: The code 'response.sendRedirect( http://www.yahoo.com; )' fails when the containing jsp is included from another jsp. Should this be failing? What am I doing wrong? By 'failing', I mean that there is no exception thrown, and no error message, but simply no redirect. e.g. (the redirect works properly when foo.jsp is called directly, but fails when foo2.jsp is called): foo2.jsp %@ page language=java import=java.lang.*,java.util.* % %@ include file=foo.jsp % foo.jsp %@ page language=java import=java.lang.*,java.util.* % % response.sendRedirect( http://www.yahoo.com; ); % - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- We don't stop playing because we grow old, we grow old because we stop playing Try not. Do. Or do not. There is no try. -Yoda Jon Beyer 412 Brown Hall Princeton University Princeton, NJ 08544 609 986 7453 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendredirect failig from an included .jsp
Howdy, Use an HttpServletRequestWrapper and override getQueryString and/or related getParameter methods. Yoav Shapira Millennium Research Informatics -Original Message- From: Jon Beyer [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 04, 2004 9:43 AM To: [EMAIL PROTECTED]; Tomcat Users List Subject: Re: response.sendredirect failig from an included .jsp Tim, Thanks for the info. The redirect that I'm trying to achieve is actually internal to my site. So I started looking at requestdispatcher.forward( ), but it appears to me that you have to simply pass the same 'request' and 'response' variables into it. I need to be able to clear the variables in the query string. Any ideas? Thanks, Jon On Tue, 03 Aug 2004 19:50:11 -0400, Tim Funk [EMAIL PROTECTED] wrote: Yes it should be failing. You cannot set headers or issue redirects from an include. (Its a rule in the spec) -Tim Jon Beyer wrote: The code 'response.sendRedirect( http://www.yahoo.com; )' fails when the containing jsp is included from another jsp. Should this be failing? What am I doing wrong? By 'failing', I mean that there is no exception thrown, and no error message, but simply no redirect. e.g. (the redirect works properly when foo.jsp is called directly, but fails when foo2.jsp is called): foo2.jsp %@ page language=java import=java.lang.*,java.util.* % %@ include file=foo.jsp % foo.jsp %@ page language=java import=java.lang.*,java.util.* % % response.sendRedirect( http://www.yahoo.com; ); % - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- We don't stop playing because we grow old, we grow old because we stop playing Try not. Do. Or do not. There is no try. -Yoda Jon Beyer 412 Brown Hall Princeton University Princeton, NJ 08544 609 986 7453 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendredirect failig from an included .jsp
The code 'response.sendRedirect( http://www.yahoo.com; )' fails when the containing jsp is included from another jsp. Should this be failing? What am I doing wrong? By 'failing', I mean that there is no exception thrown, and no error message, but simply no redirect. e.g. (the redirect works properly when foo.jsp is called directly, but fails when foo2.jsp is called): foo2.jsp %@ page language=java import=java.lang.*,java.util.* % %@ include file=foo.jsp % foo.jsp %@ page language=java import=java.lang.*,java.util.* % % response.sendRedirect( http://www.yahoo.com; ); % Thanks, Jon -- We don't stop playing because we grow old, we grow old because we stop playing Try not. Do. Or do not. There is no try. -Yoda Jon Beyer 412 Brown Hall Princeton University Princeton, NJ 08544 609 986 7453 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendredirect failig from an included .jsp
Yes it should be failing. You cannot set headers or issue redirects from an include. (Its a rule in the spec) -Tim Jon Beyer wrote: The code 'response.sendRedirect( http://www.yahoo.com; )' fails when the containing jsp is included from another jsp. Should this be failing? What am I doing wrong? By 'failing', I mean that there is no exception thrown, and no error message, but simply no redirect. e.g. (the redirect works properly when foo.jsp is called directly, but fails when foo2.jsp is called): foo2.jsp %@ page language=java import=java.lang.*,java.util.* % %@ include file=foo.jsp % foo.jsp %@ page language=java import=java.lang.*,java.util.* % % response.sendRedirect( http://www.yahoo.com; ); % - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect problem in Tomcat 5.0.18
You'll need to structure your code so that you either write to the out stream or perform a sendRedirect. There has never been a version of Tomcat that would allow otherwise. This is the same in PHP, ASP, and I imagine any other web scripting language. A sendRedirect does nothing more than send back a bodyless header with a Location: url parameter. You can't send a header once you've started writing to the body of the message. You also can't write to the body after sending a redirect (which is why you need to add a return statement just after the redirect). On Sunday 01 February 2004 06:55 am, you wrote: Hi Ben, Thanks for your assistance, I added return ; statements directly after the redirects but this didn't stop the errors. I am currently having the code checked and will let you know what eventuates. Should there be no out.print statements above the response.sendRedirect lines in the jsp code ? There are also out.write statements in the jsp code above the redirect lines, could these also cause a problem ? The code was not erroring like this when using Tomcat 4.1.24 or 5.0.16, do you think this is due to Tomcat 5.0.18 being more strict with syntax ? Thanks for your time, Regards Anthony From: Ben Souther [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: response.sendRedirect problem in Tomcat 5.0.18 Date: Sat, 31 Jan 2004 23:53:41 -0500 On Saturday 31 January 2004 11:32 pm, you wrote: at org.apache.jsp.product_jsp._jspService(product_jsp.java:283) If you go into your work directory, and look at product_jsp.java line 283, you will see exactly what's causing the problem. Without seeing your code, I can't be sure what the problem is but 99% of the time when I see an illegal state exception it caused by one of two things. Either you've written someting to the out stream before redirecting (setting content type or any out.print statements) or you didn't put a return statement just after the redirect. If neither of these is the case and you can post your code, attach your JSP and the product_jsp.java code I'll take a stab at it. -Ben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Hot chart ringtones and polyphonics. Go to http://ninemsn.com.au/mobilemania/default.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect problem in Tomcat 5.0.18
Hi All, Repost due to a spelling error - sorry: I'm having a problem with response.sendRedirect lines when running Tomcat 5.0.18. I don't have this issue when using tomcat 5.0.16. Do you know if this function has been changed in tomcat 5.0.18 ? I am able to call the respective pages successfully but not using the redirect. I'm currently running Apache 2, Tomcat 5.0.18 and jk2. The pages error with the following : * java.lang.IllegalStateException at org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:399) at org.apache.jsp.product_jsp._jspService(product_jsp.java:283) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:578) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206) at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:324) at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:395) at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673) at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615) at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:536) * TIA Anthony _ ninemsn Premium transforms your e-mail with colours, photos and animated text. Click here http://ninemsn.com.au/premium/landing.asp - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect problem in Tomcat 5.0.18
On Saturday 31 January 2004 11:32 pm, you wrote: at org.apache.jsp.product_jsp._jspService(product_jsp.java:283) If you go into your work directory, and look at product_jsp.java line 283, you will see exactly what's causing the problem. Without seeing your code, I can't be sure what the problem is but 99% of the time when I see an illegal state exception it caused by one of two things. Either you've written someting to the out stream before redirecting (setting content type or any out.print statements) or you didn't put a return statement just after the redirect. If neither of these is the case and you can post your code, attach your JSP and the product_jsp.java code I'll take a stab at it. -Ben - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what if response.sendRedirect(null)
Hi, What will happend if response.sendRedirect(null) is called. It is giving a directory listing. No error is thrown. Is this as per the spec ? I am using Tomcat 4.1.27 with JDK 1.3.1 rgds Antony Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what if response.sendRedirect(null)
The spec doesn't dictate that the parameter to sendRedirect must be non-null. So the behavior probably varies by container. Other containers might throw NPE. -Tim Antony Paul wrote: Hi, What will happend if response.sendRedirect(null) is called. It is giving a directory listing. No error is thrown. Is this as per the spec ? I am using Tomcat 4.1.27 with JDK 1.3.1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect() finite loop?!
talk2UtimeHi all, I am getting strange entries in my test_service_log.2003-12-03.txt. In my JSP which gets executed before this I am running a response.sendRedirect(/test/RedirectToMe.jsp); with a return; afterwards. So this should only get executed once. However. According to my logs its being accessed 1333 times in just SIX seconds [line count / 2]. I am the ONLY person on the server and therefore this is strange occurance! I checked the corresponding apache logs and this servlet was not in the logs, the servlet before hand which does the redirect was the only servlet that has been accessed externally. This is true from what the user sees. Is this a bug in Tomcat 4.1.29 or has something changed? I've been using Tomcat for a few years now and I've never seen anything like this? Regards, Stuart Stephen 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true ... ... ... 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true
RE: response.sendRedirect() finite loop?!
Hi, On further investigation it would appear that this is not a Tomcat issue. It seems to be something to do with mod_jk. When a response.sendRedirect occurs it does not apply it properly. Or at least something is not executing properly. The setup we have is Apache 2.0.48, Tomcat 4.1.29, and mod_jk between them working with mod_ssl. I tested the code without using apache between me and Tomcat and everything worked as expected. Any suggestions or comments?? Regards Stuart -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: 03 December 2003 10:06 To: [EMAIL PROTECTED] Subject: response.sendRedirect() finite loop?! talk2UtimeHi all, I am getting strange entries in my test_service_log.2003-12-03.txt. In my JSP which gets executed before this I am running a response.sendRedirect(/test/RedirectToMe.jsp); with a return; afterwards. So this should only get executed once. However. According to my logs its being accessed 1333 times in just SIX seconds [line count / 2]. I am the ONLY person on the server and therefore this is strange occurance! I checked the corresponding apache logs and this servlet was not in the logs, the servlet before hand which does the redirect was the only servlet that has been accessed externally. This is true from what the user sees. Is this a bug in Tomcat 4.1.29 or has something changed? I've been using Tomcat for a few years now and I've never seen anything like this? Regards, Stuart Stephen 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true ... ... ... 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect() finite loop?!
Howdy, I've never seen something like this with tomcat, and I don't know enough about mod_jk to comment intelligently. If you don't need Apache, don't use it ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 7:37 AM To: Tomcat Users List Subject: RE: response.sendRedirect() finite loop?! Hi, On further investigation it would appear that this is not a Tomcat issue. It seems to be something to do with mod_jk. When a response.sendRedirect occurs it does not apply it properly. Or at least something is not executing properly. The setup we have is Apache 2.0.48, Tomcat 4.1.29, and mod_jk between them working with mod_ssl. I tested the code without using apache between me and Tomcat and everything worked as expected. Any suggestions or comments?? Regards Stuart -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: 03 December 2003 10:06 To: [EMAIL PROTECTED] Subject: response.sendRedirect() finite loop?! talk2UtimeHi all, I am getting strange entries in my test_service_log.2003-12-03.txt. In my JSP which gets executed before this I am running a response.sendRedirect(/test/RedirectToMe.jsp); with a return; afterwards. So this should only get executed once. However. According to my logs its being accessed 1333 times in just SIX seconds [line count / 2]. I am the ONLY person on the server and therefore this is strange occurance! I checked the corresponding apache logs and this servlet was not in the logs, the servlet before hand which does the redirect was the only servlet that has been accessed externally. This is true from what the user sees. Is this a bug in Tomcat 4.1.29 or has something changed? I've been using Tomcat for a few years now and I've never seen anything like this? Regards, Stuart Stephen 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true ... ... ... 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect() finite loop?!
Also, are you using the latest mod_jk? We had some thread hangs (never saw what you are seeing), that cleared up by moving to 1.2.5 mod_jk. [EMAIL PROTECTED] 12/3/03 7:05:52 AM Howdy, I've never seen something like this with tomcat, and I don't know enough about mod_jk to comment intelligently. If you don't need Apache, don't use it ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 7:37 AM To: Tomcat Users List Subject: RE: response.sendRedirect() finite loop?! Hi, On further investigation it would appear that this is not a Tomcat issue. It seems to be something to do with mod_jk. When a response.sendRedirect occurs it does not apply it properly. Or at least something is not executing properly. The setup we have is Apache 2.0.48, Tomcat 4.1.29, and mod_jk between them working with mod_ssl. I tested the code without using apache between me and Tomcat and everything worked as expected. Any suggestions or comments?? Regards Stuart -Original Message- From: Stuart Stephen [mailto:[EMAIL PROTECTED] Sent: 03 December 2003 10:06 To: [EMAIL PROTECTED] Subject: response.sendRedirect() finite loop?! talk2UtimeHi all, I am getting strange entries in my test_service_log.2003-12-03.txt. In my JSP which gets executed before this I am running a response.sendRedirect(/test/RedirectToMe.jsp); with a return; afterwards. So this should only get executed once. However. According to my logs its being accessed 1333 times in just SIX seconds [line count / 2]. I am the ONLY person on the server and therefore this is strange occurance! I checked the corresponding apache logs and this servlet was not in the logs, the servlet before hand which does the redirect was the only servlet that has been accessed externally. This is true from what the user sees. Is this a bug in Tomcat 4.1.29 or has something changed? I've been using Tomcat for a few years now and I've never seen anything like this? Regards, Stuart Stephen 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapping contextPath='/test' with requestURI='/test/RedirectToMe.jsp' and relativeURI='/RedirectToMe.jsp' 2003-12-03 09:32:08 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RedirectToMe.jsp' and path info 'null' and update=true ... ... ... 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapping contextPath='/t2ut' with requestURI='/t2ut/RoomTimes.jsp' and relativeURI='/RoomTimes.jsp' 2003-12-03 09:32:14 StandardContext[/t2ut]: Mapped to servlet 'jsp' with servlet path '/RoomTimes.jsp' and path info 'null' and update=true - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Jeff Tulley ([EMAIL PROTECTED]) (801)861-5322 Novell, Inc., The Leading Provider of Net Business Solutions http://www.novell.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect() finite loop?!
On further investigation it would appear that this is not a Tomcat issue. It seems to be something to do with mod_jk. When a response.sendRedirect occurs it does not apply it properly. Or at least something is not executing properly. The setup we have is Apache 2.0.48, Tomcat 4.1.29, and mod_jk between them working with mod_ssl. I tested the code without using apache between me and Tomcat and everything worked as expected. Just out of curiosity, are you using mod_rewrite? If your .jsp redirects A - B, and you are rewriting B - A, then this will produce behavior similar to what you're seeing. (However, you'd also see one line for each loop iteration in Apache's access log). Are there any HTTP headers returned via response.sendRedirect(/test/RedirectToMe.jsp); (Should be an HTTP 302 with a Location: header). Also, what is the url for the servlet/jsp that makes the above call? -- Steve - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect()
Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect()
you do not lose your session, but you create a new request. /anton -Original Message- From: Duncan [mailto:[EMAIL PROTECTED] Sent: den 7 november 2003 17:36 To: Tomcat User List Subject: response.sendRedirect() Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Duncan wrote: Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Yes, do a RequestDispatcher.forward(...) instead. -- Jeanfrancois Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Oops. Just realised that my app was switching between contexts on my server, which is why I was loosing session info. Thanks for the replies thought. - Duncan. Jean-Francois Arcand wrote: Duncan wrote: Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Yes, do a RequestDispatcher.forward(...) instead. -- Jeanfrancois Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
You should only loose your session if session cookies support is disabled, and - the redirected URL has not been rewritten to add the session id, or - you redirect to another context / server in the second case the passed session id will be invalid, or ignored, depending on the case. Sometimes I have lost my session because I was not calling the getSession() in my servlet. This led my servlet engine to not properly set the response cookies. Hope it helps you, Rodrigo Ruiz Duncan wrote: Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect()
Are you redirecting from an http to an https url or vice versa? Are you redirecting to a different domain? On Friday 07 November 2003 11:35 am, Duncan wrote: Is it normal to loose your session when using the response.sendRedirect() command? If so is there a way to redirect without loosing the session? Cheers, Duncan. Decker Telecom Ltd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Ben Souther F.W. Davison Company, Inc. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect
The Servlet API doc for the sendRedirect method states: If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. I've looked thru the Servlet Spec and can not quite figure out what they mean by servlet container root ? Is this a typo and supposed to be servlet context root ? Or is there really such a thing as the servlet container root, and if so, what is it ? e.g. if my context path is /cal and I want to redirect to /cal/form/index.jsp, what would I use in sendRedirect ? (I know I could do a forward, but want to redirect in my situation) Thanks, Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect
Say you're accessing pages on localhost, so your URLs take the form http://localhost:8080/war-file/jsp-file then the servlet container root is http://localhost:8080/ and a redirect to /another-war-file/another.jsp would be a redirect to: http://localhost:8080/another-war-file/another.jsp In sendRedirect, I'm fairly sure that you simply use /cal/form/index.jsp. That sort of pattern always works for my webapps. - Original Message - From: Charlie Toohey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 05, 2003 7:07 PM Subject: response.sendRedirect The Servlet API doc for the sendRedirect method states: If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. I've looked thru the Servlet Spec and can not quite figure out what they mean by servlet container root ? Is this a typo and supposed to be servlet context root ? Or is there really such a thing as the servlet container root, and if so, what is it ? e.g. if my context path is /cal and I want to redirect to /cal/form/index.jsp, what would I use in sendRedirect ? (I know I could do a forward, but want to redirect in my situation) Thanks, Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect
The easiest way to understand this is to think about how a browser sees a relative link. Browsers don't know that they're dealing with a servlet app. A sendRedirect simply puts the following header in the response: Location: url Let's take the following url: http://www.mydomain.com/cal/index.jsp If your page index.jsp resides in the context root cal and you want to send a redirect to page2.jsp you would use page2.jsp. This tells the browser to look in the current directory for a file name page2.jsp. If you enter /page2.jsp The browser will go to what IT considers to be the webroot; the first directory after the base url http://www.mydomain.com/; and look for page2.jsp. If you're several directories below the context root and need to redirect to a higher directory, you're better off prepending one ../ to the url for each directory that you need to climb than to try to list the context root and work your way down ( /cal/page.jsp). This way, you won't need to fish through your code and change the urls if the application name cal changes. But that's just my opinion. -Ben On Friday 05 September 2003 02:07 pm, Charlie Toohey wrote: The Servlet API doc for the sendRedirect method states: If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. I've looked thru the Servlet Spec and can not quite figure out what they mean by servlet container root ? Is this a typo and supposed to be servlet context root ? Or is there really such a thing as the servlet container root, and if so, what is it ? e.g. if my context path is /cal and I want to redirect to /cal/form/index.jsp, what would I use in sendRedirect ? (I know I could do a forward, but want to redirect in my situation) Thanks, Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect
The one thing you want to watch out for with relative redirects is that they're converted by the servlet container to absolute URLs (this is in the servlet spec). This is, by the letter of the HTTP spec, the correct thing to do. Unfortunately, it can cause problems in deployments where an proxying SSL accelerator is used. These are proxies that take HTTPS requests and convert them to HTTP requests, handling all the SSL crypto stuff in the process (this technique is used in some high-volume deployments where SSL is required...the SSL stuff can be done in hardware). Consider the following: - browser requests https://visibleserver/a.jsp - a proxy SSL accelerator does the SSL processing, then forwards the request via standard HTTP to http://realserver/a.jsp - the web application does some processing, followed by a response.sendRedirect(b.jsp), which the servlet container trainslates to http://realserver/b.jsp. This is probably not what the programmer intended There are a couple of things you can do to solve this problem: * Change all sendRedirect calls to use absolute URLs. This implies that you know the absolute URL...it'd have to be a parameter to the web application, or something. OR * Implement your own sendRedirect method that sends the relative URL to the browser. This does not adhere to the HTTP spec, but all the browsers I tested seem to handle it fine (I've read elsewhere that this was the case too). Anyway, this probably isn't an issue for most people. If you have a commercial application and can't control the deployment, you should at least consider this, though. Allen -Original Message- From: Christopher Williams [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 2:22 PM To: Tomcat Users List Subject: Re: response.sendRedirect Say you're accessing pages on localhost, so your URLs take the form http://localhost:8080/war-file/jsp-file then the servlet container root is http://localhost:8080/ and a redirect to /another-war-file/another.jsp would be a redirect to: http://localhost:8080/another-war-file/another.jsp In sendRedirect, I'm fairly sure that you simply use /cal/form/index.jsp. That sort of pattern always works for my webapps. - Original Message - From: Charlie Toohey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 05, 2003 7:07 PM Subject: response.sendRedirect The Servlet API doc for the sendRedirect method states: If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. I've looked thru the Servlet Spec and can not quite figure out what they mean by servlet container root ? Is this a typo and supposed to be servlet context root ? Or is there really such a thing as the servlet container root, and if so, what is it ? e.g. if my context path is /cal and I want to redirect to /cal/form/index.jsp, what would I use in sendRedirect ? (I know I could do a forward, but want to redirect in my situation) Thanks, Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect
The one thing you want to watch out for with relative redirects is that they're converted by the servlet container to absolute URLs (this is in the servlet spec). This is, by the letter of the HTTP spec, the correct thing to do. Unfortunately, it can cause problems in deployments where an proxying SSL accelerator is used. These are proxies that take HTTPS requests and convert them to HTTP requests, handling all the SSL crypto stuff in the process (this technique is used in some high-volume deployments where SSL is required...the SSL stuff can be done in hardware). I stand corrected. I was unaware the container converted relative urls to absolute urls. That being said, the rest of what I've said still holds true, just not for the reason that I thought it does. On Friday 05 September 2003 02:53 pm, Ben Souther wrote: The easiest way to understand this is to think about how a browser sees a relative link. Browsers don't know that they're dealing with a servlet app. A sendRedirect simply puts the following header in the response: Location: url Let's take the following url: http://www.mydomain.com/cal/index.jsp If your page index.jsp resides in the context root cal and you want to send a redirect to page2.jsp you would use page2.jsp. This tells the browser to look in the current directory for a file name page2.jsp. If you enter /page2.jsp The browser will go to what IT considers to be the webroot; the first directory after the base url http://www.mydomain.com/; and look for page2.jsp. If you're several directories below the context root and need to redirect to a higher directory, you're better off prepending one ../ to the url for each directory that you need to climb than to try to list the context root and work your way down ( /cal/page.jsp). This way, you won't need to fish through your code and change the urls if the application name cal changes. But that's just my opinion. -Ben On Friday 05 September 2003 02:07 pm, Charlie Toohey wrote: The Servlet API doc for the sendRedirect method states: If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. I've looked thru the Servlet Spec and can not quite figure out what they mean by servlet container root ? Is this a typo and supposed to be servlet context root ? Or is there really such a thing as the servlet container root, and if so, what is it ? e.g. if my context path is /cal and I want to redirect to /cal/form/index.jsp, what would I use in sendRedirect ? (I know I could do a forward, but want to redirect in my situation) Thanks, Charlie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Ben Souther F.W. Davison Company, Inc. REGISTER NOW FOR THE SCORPEO USER CONFERENCE! September 18-19, 2003 in Boston/Brookline, MA Additional Training Sessions held September 17, 2003 More info http://www.fwdco.com/services/Uconf03/default.shtm - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
jk connector and response.sendRedirect()
I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. 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. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
Chris Egolf wrote: With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: jk connector and response.sendRedirect()
I'm not a programmer but an administrator. We have had an similar problem and solved it by changing the apache option UseCanonicalNames from on to off. [when UseCanonicalName ist on, everytimes you call response.sendRedirect() the apache takes the servername (from httd.conf) and make the absolute URL. If you are switching UseCanonicalNames to off, apache takes the hostname from the incoming HTTP-Header] Maybe this tip helps Regards :o) Ilona -Ursprüngliche Nachricht- Von: Chris Egolf [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 30. Juli 2003 16:18 An: [EMAIL PROTECTED] Betreff: jk connector and response.sendRedirect() I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. 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. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
John Turner wrote: Chris Egolf wrote: With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? Yes, I believe so. I added all the possible hostnames as alias to /etc/hosts (BTW, I'm running on Linux -- RH7.3). Chris -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
Chris Egolf wrote: John Turner wrote: Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? Yes, I believe so. I added all the possible hostnames as alias to /etc/hosts (BTW, I'm running on Linux -- RH7.3). Hmmm...my JkMount stuff is in the VirtualHost _default_:* sectionand the ServerName directive is the hostname the sendRedirect is failing on. -- Chris Egolf http://www.ugholf.net [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
When I use response.sendRedirect(), although redirecting to within the same context, I tend supply the whole URL. I thus avoid the kind of problems you seem to be getting. In a controller servlet where I redirect depending on the request, I do this: String urlPath = request.getScheme() + :// + request.getServerName() + : + request.getServerPort() + request.getContextPath(); I can then do this: response.sendRedirect(urlPath + /afolder/afile.jsp); Zach. Chris Egolf wrote: I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. 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. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
I'm not a programmer but an administrator. We have had an similar problem and solved it by changing the apache option UseCanonicalNames from on to off. [when UseCanonicalName ist on, everytimes you call response.sendRedirect() the apache takes the servername (from httd.conf) and make the absolute URL. If you are switching UseCanonicalNames to off, apache takes the hostname from the incoming HTTP-Header] Maybe this tip helps Regards :o) Ilona Ilona, etc. - I didn't try the UseCanonicalName option yet, but I was able to resolve this issue by specifying a VirtualHost for each possible hostname in httpd.conf. I'm glad you mentioned how response.sendRedirect() works because that's exactly the behavior I was seeing. I think it's basically doing the same thing, although getting the hostname from the incoming HTTP-Header sounds like it would be more robust. As follow up, this is what finally fixed it in httpd.conf: NameVirtualHost * VirtualHost * ServerName host.mycompany.com /VirtualHost VirtualHost * ServerName host.someotherdomain.net /VirtualHost - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
servlet response.sendRedirect() illegal state exception
Hi In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... Thanks Shanta.B -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 9:40 AM To: [EMAIL PROTECTED] Subject: ISAPI integration: Tomcat 4.1.24, IIS 5 with HTTP PUT request Hello, I am faced to the problem that the Tomcat-IIS integration doesn't work when doing some HTTP PUT Request! HTTP GET and HTTP POST requests works well. Also HTTP PUT Request works well when running Tomcat standalone (w/o IIS, Port 8080). You have some Idea? I do not. Hartmut Bernecker THE REQUEST: PUT /asim/savexml?hierid=12 HTTP/1.1 Content-Type: text/xml User-Agent: XMLSpyDocEditPlugIn Host: ep158: Content-Length: 943 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=9A85D9E5B0796C0C309DBC3EB207235F ?xml version=1.0 encoding=UTF-8? af-longtext [... some xml data ...] /af-longtext THE RESPONSE: HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.0 Date: Wed, 25 Jun 2003 14:06:05 GMT Connection: close Content-Type: text/html Content-Length: 79 htmlheadtitleError/title/headbodyFalscher Parameter. /body/html THE ISAPI-LOG: [Wed Jun 25 16:02:16 2003] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. Failed errno = 61 [Wed Jun 25 16:02:16 2003] [jk_isapi_plugin.c (928)]: HttpExtensionProc error, service() failed WORKERS PROPERTIES: worker.list=testWorker worker.testWorker.port=8009 worker.testWorker.host=localhost worker.testWorker.type=ajp13 URIWORKERMAP PROPERTIES: /myApp/*=testWorker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlet response.sendRedirect() illegal state exception
It means a response has already been committed (i.e. you have already committed to sending HTML from that servlet). Somewhere it your code you are using the printWriter or response.sendRedirect or you are already forwarding to another servlet. You should avoid having more than one response.sendRedirect/forward or controling it with if statements. You cant do this: out.print(HTML); response.sendRedirect(..); this would cause the llegal state exception. -Original Message- From: Shanta B [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 10:49 AM To: Tomcat Users List Subject: servlet response.sendRedirect() illegal state exception Hi In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... Thanks Shanta.B -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 9:40 AM To: [EMAIL PROTECTED] Subject: ISAPI integration: Tomcat 4.1.24, IIS 5 with HTTP PUT request Hello, I am faced to the problem that the Tomcat-IIS integration doesn't work when doing some HTTP PUT Request! HTTP GET and HTTP POST requests works well. Also HTTP PUT Request works well when running Tomcat standalone (w/o IIS, Port 8080). You have some Idea? I do not. Hartmut Bernecker THE REQUEST: PUT /asim/savexml?hierid=12 HTTP/1.1 Content-Type: text/xml User-Agent: XMLSpyDocEditPlugIn Host: ep158: Content-Length: 943 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=9A85D9E5B0796C0C309DBC3EB207235F ?xml version=1.0 encoding=UTF-8? af-longtext [... some xml data ...] /af-longtext THE RESPONSE: HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.0 Date: Wed, 25 Jun 2003 14:06:05 GMT Connection: close Content-Type: text/html Content-Length: 79 htmlheadtitleError/title/headbodyFalscher Parameter. /body/html THE ISAPI-LOG: [Wed Jun 25 16:02:16 2003] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. Failed errno = 61 [Wed Jun 25 16:02:16 2003] [jk_isapi_plugin.c (928)]: HttpExtensionProc error, service() failed WORKERS PROPERTIES: worker.list=testWorker worker.testWorker.port=8009 worker.testWorker.host=localhost worker.testWorker.type=ajp13 URIWORKERMAP PROPERTIES: /myApp/*=testWorker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlet response.sendRedirect() illegal state exception
Hi Tim We have one download servlet ..which is called from different servletsin download servlet we used out.println() for downloading csv files...so each servlets calls one servlet ..this servlets redirects request to download servlet... Ex: FirtServlet calls CentralServlet CentralServlet Calls Download servlet SecondServlet callls CentralServlet CentralServlet Calls Download servlet so we have used rsp.sendRedirect() in CentralServlet ...In download servlet we used both following statements PrintWriter out=new PrintWriter(rsp.getOutputStream()) out.println(messagetodownload); out.flush(); sugget me whats the alternative . -Original Message- From: Tim Davidson [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 12:17 PM To: Tomcat Users List Subject: RE: servlet response.sendRedirect() illegal state exception It means a response has already been committed (i.e. you have already committed to sending HTML from that servlet). Somewhere it your code you are using the printWriter or response.sendRedirect or you are already forwarding to another servlet. You should avoid having more than one response.sendRedirect/forward or controling it with if statements. You cant do this: out.print(HTML); response.sendRedirect(..); this would cause the llegal state exception. -Original Message- From: Shanta B [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 10:49 AM To: Tomcat Users List Subject: servlet response.sendRedirect() illegal state exception Hi In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... Thanks Shanta.B -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 9:40 AM To: [EMAIL PROTECTED] Subject: ISAPI integration: Tomcat 4.1.24, IIS 5 with HTTP PUT request Hello, I am faced to the problem that the Tomcat-IIS integration doesn't work when doing some HTTP PUT Request! HTTP GET and HTTP POST requests works well. Also HTTP PUT Request works well when running Tomcat standalone (w/o IIS, Port 8080). You have some Idea? I do not. Hartmut Bernecker THE REQUEST: PUT /asim/savexml?hierid=12 HTTP/1.1 Content-Type: text/xml User-Agent: XMLSpyDocEditPlugIn Host: ep158: Content-Length: 943 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=9A85D9E5B0796C0C309DBC3EB207235F ?xml version=1.0 encoding=UTF-8? af-longtext [... some xml data ...] /af-longtext THE RESPONSE: HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.0 Date: Wed, 25 Jun 2003 14:06:05 GMT Connection: close Content-Type: text/html Content-Length: 79 htmlheadtitleError/title/headbodyFalscher Parameter. /body/html THE ISAPI-LOG: [Wed Jun 25 16:02:16 2003] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. Failed errno = 61 [Wed Jun 25 16:02:16 2003] [jk_isapi_plugin.c (928)]: HttpExtensionProc error, service() failed WORKERS PROPERTIES: worker.list=testWorker worker.testWorker.port=8009 worker.testWorker.host=localhost worker.testWorker.type=ajp13 URIWORKERMAP PROPERTIES: /myApp/*=testWorker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlet response.sendRedirect() illegal state exception
h... I'm not sure that out.println() is the best way for downloading files (sending files to the client), but i dont know enough about file downloading and servlets to be able to help. I know there is another approach (or several appraches for that matter including setting something in the HTML header to tell the browser to request a file) but I dont know enough about it. Since you call out.println(..) your response is commited and you cant subsequently call response.sendRedirect(..). I think this is more a design issue of your approach and without knowing more about what it is you are trying to do I'm afraid i cant help. -Original Message- From: Shanta B [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 12:42 PM To: Tomcat Users List Subject: RE: servlet response.sendRedirect() illegal state exception Hi Tim We have one download servlet ..which is called from different servletsin download servlet we used out.println() for downloading csv files...so each servlets calls one servlet ..this servlets redirects request to download servlet... Ex: FirtServlet calls CentralServlet CentralServlet Calls Download servlet SecondServlet callls CentralServlet CentralServlet Calls Download servlet so we have used rsp.sendRedirect() in CentralServlet ...In download servlet we used both following statements PrintWriter out=new PrintWriter(rsp.getOutputStream()) out.println(messagetodownload); out.flush(); sugget me whats the alternative . -Original Message- From: Tim Davidson [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 12:17 PM To: Tomcat Users List Subject: RE: servlet response.sendRedirect() illegal state exception It means a response has already been committed (i.e. you have already committed to sending HTML from that servlet). Somewhere it your code you are using the printWriter or response.sendRedirect or you are already forwarding to another servlet. You should avoid having more than one response.sendRedirect/forward or controling it with if statements. You cant do this: out.print(HTML); response.sendRedirect(..); this would cause the llegal state exception. -Original Message- From: Shanta B [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 10:49 AM To: Tomcat Users List Subject: servlet response.sendRedirect() illegal state exception Hi In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... Thanks Shanta.B -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 9:40 AM To: [EMAIL PROTECTED] Subject: ISAPI integration: Tomcat 4.1.24, IIS 5 with HTTP PUT request Hello, I am faced to the problem that the Tomcat-IIS integration doesn't work when doing some HTTP PUT Request! HTTP GET and HTTP POST requests works well. Also HTTP PUT Request works well when running Tomcat standalone (w/o IIS, Port 8080). You have some Idea? I do not. Hartmut Bernecker THE REQUEST: PUT /asim/savexml?hierid=12 HTTP/1.1 Content-Type: text/xml User-Agent: XMLSpyDocEditPlugIn Host: ep158: Content-Length: 943 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=9A85D9E5B0796C0C309DBC3EB207235F ?xml version=1.0 encoding=UTF-8? af-longtext [... some xml data ...] /af-longtext THE RESPONSE: HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.0 Date: Wed, 25 Jun 2003 14:06:05 GMT Connection: close Content-Type: text/html Content-Length: 79 htmlheadtitleError/title/headbodyFalscher Parameter. /body/html THE ISAPI-LOG: [Wed Jun 25 16:02:16 2003] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. Failed errno = 61 [Wed Jun 25 16:02:16 2003] [jk_isapi_plugin.c (928)]: HttpExtensionProc error, service() failed WORKERS PROPERTIES: worker.list=testWorker worker.testWorker.port=8009 worker.testWorker.host=localhost worker.testWorker.type=ajp13 URIWORKERMAP PROPERTIES: /myApp/*=testWorker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlet response.sendRedirect() illegal state exception
Howdy, In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... It's actually pretty clearly indicates in the JavaDoc for HttpServletResponse#sendRedirect. Don't write to the response before redirecting it. If you can help it, don't even open a writer or output stream to the response before redirecting it. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: servlet response.sendRedirect() illegal state exception
Hi I find the problem ...and i rectify it ... -Original Message- From: Tim Davidson [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 12:17 PM To: Tomcat Users List Subject: RE: servlet response.sendRedirect() illegal state exception It means a response has already been committed (i.e. you have already committed to sending HTML from that servlet). Somewhere it your code you are using the printWriter or response.sendRedirect or you are already forwarding to another servlet. You should avoid having more than one response.sendRedirect/forward or controling it with if statements. You cant do this: out.print(HTML); response.sendRedirect(..); this would cause the llegal state exception. -Original Message- From: Shanta B [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 10:49 AM To: Tomcat Users List Subject: servlet response.sendRedirect() illegal state exception Hi In my servlet response.sendRedirect i am getting illegal state exception ...could pl tell me how to avoid this...whats does it mean... Thanks Shanta.B -Original Message- From: Hartmut Bernecker [mailto:[EMAIL PROTECTED] Sent: Thursday, June 26, 2003 9:40 AM To: [EMAIL PROTECTED] Subject: ISAPI integration: Tomcat 4.1.24, IIS 5 with HTTP PUT request Hello, I am faced to the problem that the Tomcat-IIS integration doesn't work when doing some HTTP PUT Request! HTTP GET and HTTP POST requests works well. Also HTTP PUT Request works well when running Tomcat standalone (w/o IIS, Port 8080). You have some Idea? I do not. Hartmut Bernecker THE REQUEST: PUT /asim/savexml?hierid=12 HTTP/1.1 Content-Type: text/xml User-Agent: XMLSpyDocEditPlugIn Host: ep158: Content-Length: 943 Connection: Keep-Alive Cache-Control: no-cache Cookie: JSESSIONID=9A85D9E5B0796C0C309DBC3EB207235F ?xml version=1.0 encoding=UTF-8? af-longtext [... some xml data ...] /af-longtext THE RESPONSE: HTTP/1.1 500 Server Error Server: Microsoft-IIS/5.0 Date: Wed, 25 Jun 2003 14:06:05 GMT Connection: close Content-Type: text/html Content-Length: 79 htmlheadtitleError/title/headbodyFalscher Parameter. /body/html THE ISAPI-LOG: [Wed Jun 25 16:02:16 2003] [jk_ajp_common.c (1318)]: Error connecting to tomcat. Tomcat is probably not started or is listening on the wrong port. Failed errno = 61 [Wed Jun 25 16:02:16 2003] [jk_isapi_plugin.c (928)]: HttpExtensionProc error, service() failed WORKERS PROPERTIES: worker.list=testWorker worker.testWorker.port=8009 worker.testWorker.host=localhost worker.testWorker.type=ajp13 URIWORKERMAP PROPERTIES: /myApp/*=testWorker - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect() and the servlet path?
Hi, if I have a context path such as /mycontext and I use response.sendRedirect(/foo.jsp), the container should translate that into a full url such as http://myserver/mycontext/foo.jsp, instead of http://myserver/foo.jsp. However, it seems that this is not happening. Am I doing something wrong, or is there a bug, or ??? Thanks for any help on this. __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() and the servlet path?
My reading of section 5.3 of the servlet-spec (version=2.3), says that you are wrong. Paths to sendRedirect are normal URL patterns, and are *not* based on the calling Context. joe user [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, if I have a context path such as /mycontext and I use response.sendRedirect(/foo.jsp), the container should translate that into a full url such as http://myserver/mycontext/foo.jsp, instead of http://myserver/foo.jsp. However, it seems that this is not happening. Am I doing something wrong, or is there a bug, or ??? Thanks for any help on this. __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect( .. )
One reason is this: After a redirect the servlet that issues the redirect will continue to run unless you stop the processing with a return statement directly after the redirect. Now consider this example: Servlet A: doSomething(); include(Servlet B); doSomethingMore(); Servlet B: doSomeOtherThing(); if (condition) { respose.sendRedirect(); return; } doMoreOtherThings(); This will stop Servlet B from processing doMoreOtherThings() after the redirect, but Servlet A will still execute doSomethingMore(). One other thing with sendRedirect() is, that it is a good practice to do the redirect as early as possible. The later you do it, the higher gets the risk that the response header has already been sent to the client. (If you produced enough output to force a flush of the outputbuffer) -Original Message- From: Geoff Coffey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 12:49 AM To: Tomcat Users List Subject: Re: response.sendRedirect( .. ) Does anybody know the reason for this limitation? Does anybody have a better way to accomplish what I'm describing? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
After a redirect the servlet that issues the redirect will continue to run unless you stop the processing with a return statement directly after the redirect. Now consider this example: [...] This will stop Servlet B from processing doMoreOtherThings() after the redirect, but Servlet A will still execute doSomethingMore(). One other thing with sendRedirect() is, that it is a good practice to do the redirect as early as possible. [...] Yes, but this just seems like a weakness in the model really. In our case, the redirect was sent in every case before anything of significance was added to the content of the response, so we never would have run in to a committed response issue. The fact that my JSP page turns in to a servlet behind-the-scenes, and that servlet model doesn't handle redirects in includes because of a code organization problem seems arbitrary and inappropriate. I would expect sendRedirect() to abort the response anyway, although someone may have a good reason to include content in a 302 response. A forward, on the other hand, does abort the response, so it is even more arbitrary that forwards don't work in includes. It seems like this is a case where a weakness in the model at a low level rears its head at the very highest level (JSP), which is, IMO, a bad thing. And the docs don't seem clear on this point at all. We only were able to confirm that redirects and forwards don't work in includes by examining the generated .java files and reading the docs on the servlet stuff. The JSP docs don't seem to mention it (I may be missing it...) Here's the relevant docs: sendRedirect public void sendRedirect (String location) throws IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. 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. Parameters: location - the redirect location URL Throws: IOException - If an input or output exception occurs IllegalStateException - If the response was committed and jsp:forward Forwards a client request to an HTML file, JSP file, or servlet for processing. JSP Syntax jsp:forward page={ relativeURL | %= expression %} / or jsp:forward page={ relativeURL | %= expression %} jsp:param name= parameterName value={ parameterValue | %= expression %} /+ /jsp:forward Examples jsp:forward page=/servlet/login / jsp:forward page=/servlet/login jsp:param name=username value=jsmith / /jsp:forward Description The jsp:forward element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file. The lines in the source JSP file after the jsp:forward element are not processed. You can pass parameter names and values to the target file by using a jsp:param clause. An example of this would be passing the parameter name username (with name=username ) and the value scott (with value=scott )to a servlet login file as part of the request. If you use jsp:param , the target file should be a dynamic file that can handle the parameters. Be careful when using jsp:forward with unbuffered output. If you have used the %@ page % directive with buffer=none to specify that the output of your JSP file should not be buffered, and if the JSP file has any data in the out object, using jsp:forward will cause an IllegalStateException . Attributes page={ relativeURL | %= expression %} AString or an expression representing the relative URL of the file to which you are forwarding the request. The file can be another JSP file, a servlet, or any other dynamic file that can handle a request object. The relative URL looks like a path-it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP file. If it is absolute (beginning with a /), the path is resolved by your Web or application server. jsp:param name= parameterName value={ parameterValue | %= expression %} /+ Sends one or more name/value pairs as parameters to a dynamic file. The target file should be dynamic, that is, a JSP file, servlet, or other file that can process the data that is sent to it as parameters. You can use more than one jsp:param clause if you need to send more than one parameter to the target file. The name
Re: response.sendRedirect( .. )
Section 4.4 of the Jsp spec: An included page only has access to the JspWriter object and it cannot set headers. This precludes invoking methods like setCookie(). Attempts to invoke these methods will be ignored. The constraint is equivalent to the one imposed on the include() method of the RequestDispatcher class. So jsp:include also has all the same restrictions imposed by RequestDispatcher.include(). As for th 302 errors, from the RFC: http://www.ietf.org/rfc/rfc2616.txt ... The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). I paraphrase as its nice to present some body content in your page since browsers/agents do have the option of displaying/parsing the body for some context before following the redirect. -Tim Geoff Coffey wrote: [...] I would expect sendRedirect() to abort the response anyway, although someone may have a good reason to include content in a 302 response. A forward, on the other hand, does abort the response, so it is even more arbitrary that forwards don't work in includes. It seems like this is a case where a weakness in the model at a low level rears its head at the very highest level (JSP), which is, IMO, a bad thing. And the docs don't seem clear on this point at all. We only were able to confirm that redirects and forwards don't work in includes by examining the generated .java files and reading the docs on the servlet stuff. The JSP docs don't seem to mention it (I may be missing it...) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
On Wednesday, March 5, 2003, at 08:32 AM, Tim Funk wrote: I paraphrase as its nice to present some body content in your page since browsers/agents do have the option of displaying/parsing the body for some context before following the redirect. I stand corrected on that point, although I've never followed this guidance in 8 years, and I've never seen a user agent that didn't follow redirects immediately. I've also never seen anyone else do this. But none-the-less, it would be wrong, then, for redirect to abort the response. Thanks again, tim. Geoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
Geoff Coffey wrote: On Wednesday, March 5, 2003, at 08:32 AM, Tim Funk wrote: I paraphrase as its nice to present some body content in your page since browsers/agents do have the option of displaying/parsing the body for some context before following the redirect. I stand corrected on that point, although I've never followed this guidance in 8 years, and I've never seen a user agent that didn't follow redirects immediately. You're probably thinking of browsers. Spiders and other scripts, on the other hand, might not be so kind, esp since you're trying to use redirect to prevent access to a restricted area. For instance, in CGI environments, after setting the Location header (equivalent of sendRedirect) it is always wise to immediately exit the script so that no further content is sent along with the header. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
Geoff Coffey wrote: It seems like we need our authentication check and redirect (or forward) on the content page itself and not in an include, so Muffi created a taglib to encapsulate this check and that seems to be working. Is this a typical solution? It seems like a frustrating restriction to prevent redirects or forwards in includes. Does anybody know the reason for this limitation? Does anybody have a better way to accomplish what I'm describing? I know a lot of people prefer container-managed authentication, but my own approach has been similar to yours. At first I tried doing the exact same thing, which is how I would have done it in my old language, PHP. But with servlets/JSP, I think a better way to do this (that works well for me) is to write a filter and map that filter to any sensitive URLs. The filter does the authentication check, and has the ability to perform the sendRedirect with no problems (unlike a runtime JSP include using jsp:forward). Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect( .. )
I have 3 machines that I support with broken browsers that don't follow redirects immediately. In fact if the page includes any content, any at all, the ignore the redirect. I'm not 100% sure, but I even thing they ignore meta tag redirects. --mikej -=- mike jackson [EMAIL PROTECTED] -Original Message- From: Geoff Coffey [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2003 7:39 AM To: Tomcat Users List Subject: Re: response.sendRedirect( .. ) On Wednesday, March 5, 2003, at 08:32 AM, Tim Funk wrote: I paraphrase as its nice to present some body content in your page since browsers/agents do have the option of displaying/parsing the body for some context before following the redirect. I stand corrected on that point, although I've never followed this guidance in 8 years, and I've never seen a user agent that didn't follow redirects immediately. I've also never seen anyone else do this. But none-the-less, it would be wrong, then, for redirect to abort the response. Thanks again, tim. Geoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
On Wednesday, March 5, 2003, at 09:41 AM, Mike Jackson wrote: I have 3 machines that I support with broken browsers that don't follow redirects immediately. In fact if the page includes any content, any at all, the ignore the redirect. I'm not 100% sure, but I even thing they ignore meta tag redirects. If they ignore redirects that contain content, then following the HTTP spec guidance would exacerbate the problem, not solve it. The guidance was to always include some content on redirect responses, which I have never done. Hmmm...seems to be some uncertainty about this :( I'm going to try including content from now on just to be well behaved, but if I too see problems, I'll have to rethink that. At least browsers aren't half as bad as in the past :) Geoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect( ); question
I have a .jsp page which has the following contents: / /--- html % // if the user is not authenticated, we need to send them to the login page if(session.getAttribute(USER_AUTHORIZED) == null || session.getAttribute(USER_AUTHORIZED).equals(false)) { response.sendRedirect(/login/Login.jsp); } % body pI don't know why this is being called when the user is not already authenticated /p /body /html / /--- Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? This used to work in Tomcat 3.XX i recently upgraded to Tomcat 4.1.18 .. is there some change in the behaviour of response.sendRedirect () ? thanks.
response.sendRedirect( ); question
I have a .jsp page which has the following contents: / /--- html % // if the user is not authenticated, we need to send them to the login page if(session.getAttribute(USER_AUTHORIZED) == null || session.getAttribute(USER_AUTHORIZED).equals(false)) { response.sendRedirect(/login/Login.jsp); } % body pI don't know why this is being called when the user is not already authenticated /p /body /html / /--- Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? This used to work in Tomcat 3.XX i recently upgraded to Tomcat 4.1.18 .. is there some change in the behaviour of response.sendRedirect () ? thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( ); question
Mufaddal Khumri wrote: Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? Try putting a return; statement immediately after the call to sendRedirect. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( ); question
Adding a return does not work. Infact I tried to add this to the top of my page %@ page buffer=32KB autoFlush=true % This throws the following error: 2003-03-04 14:19:07 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception org.apache.jasper.JasperException: /include/header.jsp(0,113) jsp.error.buffer.invalid at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHand ler.java:94) at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java :428) at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java :140) at org.apache.jasper.compiler.Validator$PageDirectiveVisitor.visit(Validato r.java:183) at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:280) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028) at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070) at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076) at org.apache.jasper.compiler.Node$Root.accept(Node.java:232) at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028) at org.apache.jasper.compiler.Validator.validate(Validator.java:581) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:226) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja va:474) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:184) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatc her.java:684) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDisp atcher.java:575) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispat cher.java:498) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.ja va:822) at org.apache.jsp.Catalog_jsp._jspService(Catalog_jsp.java:42) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja va:204) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica tionFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt erChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv e.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv e.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.ja va:246) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241 5) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java :180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa lve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java :172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve. java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i nvokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4 80) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at
Re: response.sendRedirect( ); question
Mufaddal Khumri wrote: Adding a return does not work. Well, it was worth a try. Sorry it didn't work out. My own approach (modeled after the conventional wisdom tossed about on this list and in some tutorials I have read) is to refrain from using decision logic in JSPs wherever possible. Some people call it the MVC approach, I typically have a servlet as the target resource of all HTTP requests, which does the decision making and then calls dispatcher.forward() on a JSP to generate the HTML to send to the browser. I have not had any problem calling sendRedirect from a servlet. If I absolutely must have conditional logic in the JSP I try to put it into a custom tag. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect( .. )
I have a .jsp page which has the following contents: / /--- html % // if the user is not authenticated, we need to send them to the login page if(session.getAttribute(USER_AUTHORIZED) == null || session.getAttribute(USER_AUTHORIZED).equals(false)) { System.out.println(Before redirect); response.sendRedirect(/login/Login.jsp); System.out.println(After redirect); } % body pI don't know why this is being called when the user is not already authenticated /p /body /html / /--- Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? I checked if the if block was being entered by putting the two System.out.println( .. ) statements .. and when i call this JSP from my browser .. both those statements get printed onto the console. This used to work in Tomcat 3.XX i recently upgraded to Tomcat 4.1.18 .. is there some change in the behaviour of response.sendRedirect () ? thanks. - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
If this page is being called via a jsp:include - your out of luck. You cannot perform a sendRedirect() inside of an include. It's not tomcat's fault - it specified by the JSP spec. -Tim Mufaddal Khumri wrote: I have a .jsp page which has the following contents: / /--- html % // if the user is not authenticated, we need to send them to the login page if(session.getAttribute(USER_AUTHORIZED) == null || session.getAttribute(USER_AUTHORIZED).equals(false)) { System.out.println(Before redirect); response.sendRedirect(/login/Login.jsp); System.out.println(After redirect); } % body pI don't know why this is being called when the user is not already authenticated /p /body /html / /--- Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? I checked if the if block was being entered by putting the two System.out.println( .. ) statements .. and when i call this JSP from my browser .. both those statements get printed onto the console. This used to work in Tomcat 3.XX i recently upgraded to Tomcat 4.1.18 .. is there some change in the behaviour of response.sendRedirect () ? thanks. - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
Yes This is used from within an include. so how would I redirect ? Thanks. On Wednesday, March 5, 2003, at 03:20 AM, Tim Funk wrote: If this page is being called via a jsp:include - your out of luck. You cannot perform a sendRedirect() inside of an include. It's not tomcat's fault - it specified by the JSP spec. -Tim Mufaddal Khumri wrote: I have a .jsp page which has the following contents: / /- -- html % // if the user is not authenticated, we need to send them to the login page if(session.getAttribute(USER_AUTHORIZED) == null || session.getAttribute(USER_AUTHORIZED).equals(false)) { System.out.println(Before redirect); response.sendRedirect(/login/Login.jsp); System.out.println(After redirect); } % body pI don't know why this is being called when the user is not already authenticated /p /body /html / /- -- Now if the USER_AUTHORIZED attribute is not set, it will enter the if block and get redirected to the login.jsp page. The browser shows me the content of the body page after the if block instead. Does after getting redirected the call returns to this page and completes the processing of this page ? I checked if the if block was being entered by putting the two System.out.println( .. ) statements .. and when i call this JSP from my browser .. both those statements get printed onto the console. This used to work in Tomcat 3.XX i recently upgraded to Tomcat 4.1.18 .. is there some change in the behaviour of response.sendRedirect () ? thanks. - - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
You can do a compile time include instead of a run-time include. -Tim Mufaddal Khumri wrote: Yes This is used from within an include. so how would I redirect ? Thanks. On Wednesday, March 5, 2003, at 03:20 AM, Tim Funk wrote: If this page is being called via a jsp:include - your out of luck. You cannot perform a sendRedirect() inside of an include. It's not tomcat's fault - it specified by the JSP spec. -Tim - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
You can do a compile time include instead of a run-time include. Tim: We wanted to avoid that because we're including quite a lot of stuff, and it is being included on every page. Naively, I felt that duplicating all that header and footer logic and HTML in every generated servlet would be unwise. But I'm very new to this, so I may be off base. The general setup is that we have the typical standardized header and footer, and some standardized, but conditional, navigation stuff. This is all part of two include files called, aptly, Header.jsp and Footer.jsp. These files are included on nearly every page, so that the page itself only needs to define its unique content. Our header performs the requisite check that the user is authenticated, and attempts to redirect to the login page if not. For some reason it worked fine until recently, perhaps coinciding with our switch to the latest stable tomcat. It seems like we need our authentication check and redirect (or forward) on the content page itself and not in an include, so Muffi created a taglib to encapsulate this check and that seems to be working. Is this a typical solution? It seems like a frustrating restriction to prevent redirects or forwards in includes. Does anybody know the reason for this limitation? Does anybody have a better way to accomplish what I'm describing? Thanks for all your help so far! Geoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect( .. )
(Sorry for the ramblings ...) Yes - creating a taglib is much, much better than a compile time include. My only reason of recommendation for a compile time include was because that was the easiest and quickest fix - but also the worst. There are a few ways to perform authentication. Each has their own merits. - Use a custom tag that will force an abort/redirect of the page - Use a filter - Use the servlet api' security constraints A custom tag offers the most flexibility since it is easiest it is the easiest way to perform granular access. But this method has the drawback of reinventing the wheel with respect to page protection. A filter is nice since the pages to be protected don't need to know whether they are being protected or not. This leaves the coding of the page MUCH cleaner and easier to maintain. Filters can also be selectively run on only mappings defined in web.xml. Filters also have the abolity to be run on every request and you can create your own wacky rules too. The prefered way is via the servlet sepcification. This method relies on the spec and the brain pwoer of a lot of smart people trying to think of how to solve the exact problem you had. But on the bad side, it is also a lot of smart people from different organizations with their own agenda so for some people - this method is completely unworkable to them. But this method is the best since ultimately security is taken out of the hadns of the programmer and placed into the hands of the system administrator or configurator. This method still relies on developer support but offers the most flexibility if you can plan on using this first. Pertaining to the topic below of using a header.jsp and footer.jsp. We have the same mess, and I emphasize mess. Many of my pages include a header, then do stuff, then a footer. I inherited it and hate it. Luckily the consulting firm that did this to me is long gone. Since then we have done the following to fix messes like this: - Get a real content management system. Let it republish all the HTML file when stuff changes. For us, navigation doesn't change very often so mass publishes aren't very painful. - Custom tags are your friend. For newer parts of my site, I have created a 3 custom tags which handle my header/footer/nav hell. So now my pages look like this: foo:html foo:head Any extra stuff which needs to appear in head tag goes here. Otherwise this tag just places the normal stuff that would appear in the head tag here. /foo:head foo:body print=true width=800 Body of page goes here. /foo:body /foo:html It is the job of the head and body tags to pull in the appropriate navs at the right time and plop them on the page. Currently the tags are a mess which involve some printlns, but mainly it has many includes from other assets. If I code the body of my page well - I can easily turn the same page into a printer friendy page or even a mobile device friendly page with these tags. (If I felt masochistic). But the above also has issues too if your site is content heavy and each content page becomes a JSP. In that case - you should really be publishing your content in an intermediate format and have it transformed dynamically by a single servlet instance so hundreds (or thousands) or JSP's are not instantiated on your server. -Tim Geoff Coffey wrote: You can do a compile time include instead of a run-time include. Tim: We wanted to avoid that because we're including quite a lot of stuff, and it is being included on every page. Naively, I felt that duplicating all that header and footer logic and HTML in every generated servlet would be unwise. But I'm very new to this, so I may be off base. The general setup is that we have the typical standardized header and footer, and some standardized, but conditional, navigation stuff. This is all part of two include files called, aptly, Header.jsp and Footer.jsp. These files are included on nearly every page, so that the page itself only needs to define its unique content. Our header performs the requisite check that the user is authenticated, and attempts to redirect to the login page if not. For some reason it worked fine until recently, perhaps coinciding with our switch to the latest stable tomcat. It seems like we need our authentication check and redirect (or forward) on the content page itself and not in an include, so Muffi created a taglib to encapsulate this check and that seems to be working. Is this a typical solution? It seems like a frustrating restriction to prevent redirects or forwards in includes. Does anybody know the reason for this limitation? Does anybody have a better way to accomplish what I'm describing? Thanks for all your help so far! Geoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() - is this allowed?
if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } You need to be careful doing this actually... While it will work in most cases, if the data + URL is longer than 2048 bytes it will fail (for RFC-compliant browsers) as 2048 bytes is the limit on GET. In this case data will be truncated after 2048 bytes and there is a risk of crashes or incorrect data being sent to the process-function. GET also exposes all the arguments on the URL line which can be messy and dangerous if the form contained sensitive information. If the data length + URL length is longer than 2048 bytes, or to stop double-posts, use the following method, which is sometimes called POST-cleaning: - Use POST as the method - When the servlet/JSP processes the POST, first check the data and display error messages for missing-data etc.. (data-validation). - If there are no errors, *do not* output anything, just process the data. - After processing, use sendRedirect() to send the user to a page that displays the output (eg: Thankyou for your submission, or Update successful, or send them back to the menu etc..). Now the final page is retrieved with a GET, has no 2k-limit on the data for thr processing, and has no displayed URL params. - Instead of setting sendRedirect(), also consider using setHeader calls to set the status to 302 with the new location, and also output a meta-refresh tag which sends the user to the final page and/or some javascript which sends them to the final page (or at worst a link saying click here to continue). Now you have 4 methods to make sure they continue to the result-page instead of relying on the 302. - Use sessions or a URL token to maintain the state, because after sendRedirect(), the servlet will be called again with a GET, and you will need some way to figure out who the client is and what data was submitted in case you need to display it again. Hope that helps, Neale Rudd metawerx java hosting http://www.metawerx.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: response.sendRedirect() - is this allowed?
Arbitrarily changing a POST to a GET can also end up in your customers ordering two sets of football tickets, rather than one. A repeat of a POST requires that the user be prompted, as POSTs are non-idempotent. Browsers can issue as many GET requests as they like in order to get the page downloaded (IE, for example, appears to just repeat a GET request if looks like the first attempt is taking too long). And as Neale says, having things like credit card numbers, passwords, etc., in your browser history isn't ideal. Finally, here's what HTTP/1.1 has to say on URI lengths: The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15). Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths. (from 3.2.1, General Syntax). We've run into a number of problems in the past in which application servers have transformed POSTs into GETs for their own internal reasons (usually to munge things into some MVC-esque structure), and dissappeared parameters off the end of the list. Very frustrating, and very tedious to debug :( Dan. -Original Message- From: Neale [mailto:[EMAIL PROTECTED]] Sent: 07 February 2003 09:01 To: Tomcat Users List Subject: Re: response.sendRedirect() - is this allowed? if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } You need to be careful doing this actually... While it will work in most cases, if the data + URL is longer than 2048 bytes it will fail (for RFC-compliant browsers) as 2048 bytes is the limit on GET. In this case data will be truncated after 2048 bytes and there is a risk of crashes or incorrect data being sent to the process-function. GET also exposes all the arguments on the URL line which can be messy and dangerous if the form contained sensitive information. If the data length + URL length is longer than 2048 bytes, or to stop double-posts, use the following method, which is sometimes called POST-cleaning: - Use POST as the method - When the servlet/JSP processes the POST, first check the data and display error messages for missing-data etc.. (data-validation). - If there are no errors, *do not* output anything, just process the data. - After processing, use sendRedirect() to send the user to a page that displays the output (eg: Thankyou for your submission, or Update successful, or send them back to the menu etc..). Now the final page is retrieved with a GET, has no 2k-limit on the data for thr processing, and has no displayed URL params. - Instead of setting sendRedirect(), also consider using setHeader calls to set the status to 302 with the new location, and also output a meta-refresh tag which sends the user to the final page and/or some javascript which sends them to the final page (or at worst a link saying click here to continue). Now you have 4 methods to make sure they continue to the result-page instead of relying on the 302. - Use sessions or a URL token to maintain the state, because after sendRedirect(), the servlet will be called again with a GET, and you will need some way to figure out who the client is and what data was submitted in case you need to display it again. Hope that helps, Neale Rudd metawerx java hosting http://www.metawerx.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
response.sendRedirect() - is this allowed?
Hello, Tomcat User's List, There was some talk a few days ago about response.sendRedirect() after a POST request being against the HTTP specification... is that really true? For example, would this be a problem? IE and Netscape seem to do what I want! // This is common trick I use after a form submission to // help make navigation easier for the user, and to help // avoid dual-submission of the same form. // // request is an HttpServletRequest and response // is an HttpServletResponse. if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } I would appreciate any advice anyone might have. yours, Julius Davies, Programmer, CUCBC Email: [EMAIL PROTECTED], Ph: 604.730.6385 This email represents my personal opinions and concerns and not those of CUCBC. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() - is this allowed?
It isn't against the HTTP specification to sendRedirect (which in Tomcat will result in a 302 response). It's just that very few (if any) browsers actually implement the spec in this area. Most of them will respond by doing a GET to the new URL, instead of a POST (which is what the RFC says to do). If you wanted to be completely safe with broken browsers, then you should also add the POSTed parameters to the query string in your example below. Julius Davies [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Tomcat User's List, There was some talk a few days ago about response.sendRedirect() after a POST request being against the HTTP specification... is that really true? For example, would this be a problem? IE and Netscape seem to do what I want! // This is common trick I use after a form submission to // help make navigation easier for the user, and to help // avoid dual-submission of the same form. // // request is an HttpServletRequest and response // is an HttpServletResponse. if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } I would appreciate any advice anyone might have. yours, Julius Davies, Programmer, CUCBC Email: [EMAIL PROTECTED], Ph: 604.730.6385 This email represents my personal opinions and concerns and not those of CUCBC. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() - is this allowed?
// This is common trick I use after a form submission to // help make navigation easier for the user, and to help // avoid dual-submission of the same form. // Not clear - how is the second submission avoided? if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } I have been using this technique for quite some time but I am not happy as all the POST data appears in the query string straight away. What is a better way of passing data(possibly huge) to a redirected url? RequestDispatcher would do but I dont see the redirected url at the browser if I use it. ~rf __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() - is this allowed?
rf [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... // This is common trick I use after a form submission to // help make navigation easier for the user, and to help // avoid dual-submission of the same form. // Not clear - how is the second submission avoided? if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } I have been using this technique for quite some time but I am not happy as all the POST data appears in the query string straight away. What is a better way of passing data(possibly huge) to a redirected url? RequestDispatcher would do but I dont see the redirected url at the browser if I use it. The above code is harmless, and will work with any browser that actually implements the RFC (AFAIK, this is the empty set :). For broken browsers, you have the choice of either storing the POST data in the session (and use URL re-writing for safety), or copying it to the query-string. ~rf __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: response.sendRedirect() - is this allowed?
Further to this, the W3 recognized the fact that many clients did not adhere to the specification for 302 and 303, so they introduced 307 in HTTP 1.1--which was intended to be followed more strictly. The original method must be used when following a re-direct, but when a non-idempotent method is used (i.e.: POST), the client must obtain confirmation from the user before following the re-direct. Only handled by HTTP 1.1 capable browsers only. :-( At 20:50 2003-02-06 -0800, you wrote: It isn't against the HTTP specification to sendRedirect (which in Tomcat will result in a 302 response). It's just that very few (if any) browsers actually implement the spec in this area. Most of them will respond by doing a GET to the new URL, instead of a POST (which is what the RFC says to do). If you wanted to be completely safe with broken browsers, then you should also add the POSTed parameters to the query string in your example below. Julius Davies [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello, Tomcat User's List, There was some talk a few days ago about response.sendRedirect() after a POST request being against the HTTP specification... is that really true? For example, would this be a problem? IE and Netscape seem to do what I want! // This is common trick I use after a form submission to // help make navigation easier for the user, and to help // avoid dual-submission of the same form. // // request is an HttpServletRequest and response // is an HttpServletResponse. if ( POST.equalsIgnoreCase( request.getMethod() ) ) { StringBuffer buf = new StringBuffer(); buf.append( request.getRequestURI() ); buf.append( ? ); buf.append( request.getQueryString() ); response.sendRedirect( buf.toString() ); return; } I would appreciate any advice anyone might have. yours, Julius Davies, Programmer, CUCBC Email: [EMAIL PROTECTED], Ph: 604.730.6385 This email represents my personal opinions and concerns and not those of CUCBC. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Sean Dockery [EMAIL PROTECTED] Certified Java Web Component Developer Certified Delphi Programmer SBD Consultants http://www.sbdconsultants.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using response.sendRedirect() with POST
Is there any way to encode parameters into a redirected response WITHOUT just encoding them into the URL like this: response.sendRedirect( /errorpage.jsp?errorcode=12 ); I'd like for it to be transparent to the user, using post, or some other invisible method like the request.setAttribute( errorcode, 12 ); dispatcher.forward( request, response ); method when using a requestDispatcher, but I _do_ want the user to see the main URL, so I can't use the dispatcher, (I don't think...) Thanks in advance :) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Using response.sendRedirect() with POST
Is there any way to encode parameters into a redirected response WITHOUT just encoding them into the URL like this: - cookies - session attributes You could encode the data in a cookie, and retrieve it in your target page. Alternatively, you could put the data into one or more session beans. If you are not familar with the jsp:useBean tag, see the JSP specification (and HttpSession.set/getAttribute). --- Noel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
bug in response.sendRedirect with WARP?
Hi, I have found an apparent bug with Tomcat 4.0.1 and the WARP connector. When my JSP page calls response.sendRedirect() through the Apache webapp (WARP) Engine, nothing happens. (I do this when given a bad login, for example). When I access the page through Tomcat directly (port 8080) this works fine. I'm theorizing that this happens because response.sendRedirect constructs a new URL with an invalid port, namely the Port used to communicate between Apache and Tomcat. If this is true, is there a way to specify the port for all redirects? On a related note, I cannot seem to get the welcome page to show up properly under warp. I suspect this is the same problem. http://server:8080/report/ redirects to index.jsp http://server/report/ gives a page not found error Help on this redirect issue would be appreciated. I couldn't find any mention of it in the archive, but I suspect it must affect a number of users. WILL BEGIN:VCARD VERSION:3.0 PRODID:-//Gordano//NONSGML GLWebMail 7.02.3037//EN REV:2002-08-22T18:59:28Z NICKNAME:Will FN:Will Glass-Husain N:Glass-Husain;Will;;; EMAIL;TYPE=INTERNET:[EMAIL PROTECTED] END:VCARD -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
I do not call response.sendRedirect(url) with https
Hi, can tell me why I can not make a response.sendRedirect(url) in https protocol? I use apache with mod_ssl and Tomcat with mod_webapps Thanks for your help
RequestDispatcher forward versus response.sendRedirect
Anyone have any hard and fast rules, good links, general info, do and don't lists, or anything about these two? We moved from iPlanet 4.1 where we did all redirection with response.sendRedirect. That didn't work with tomcat so I started using the forward method of RequestDispatcher. Well, now I need to use a NON relative path to redirect the user off our site. While I think response.sendRedirect will work in this instance I cannot seem to formulate a theory why it works here and not in other parts of our site. Does anyone have any information on this I can read, or advice? Thanks! Jason -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: RequestDispatcher forward versus response.sendRedirect
302 temporarily moved error. -Original Message- From: Sullivan, Mark E [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:13 AM To: 'Tomcat Users List' Subject: RE: RequestDispatcher forward versus response.sendRedirect when you say response.sendRedirect doesn't work, what kind of error/unexpected behavior are you getting? -Original Message- From: Jason Stortz [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:12 AM To: Tomcat Users List Subject: RequestDispatcher forward versus response.sendRedirect Anyone have any hard and fast rules, good links, general info, do and don't lists, or anything about these two? We moved from iPlanet 4.1 where we did all redirection with response.sendRedirect. That didn't work with tomcat so I started using the forward method of RequestDispatcher. Well, now I need to use a NON relative path to redirect the user off our site. While I think response.sendRedirect will work in this instance I cannot seem to formulate a theory why it works here and not in other parts of our site. Does anyone have any information on this I can read, or advice? Thanks! Jason -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: RequestDispatcher forward versus response.sendRedirect
Hi, Jason. I believe that that is precisely the intended use of the response.sendRedirect ... when you are redirecting OFF your site (to an absolute path). The specs say that sendRedirect takes an absolute path, so it is not good to use for forwarding around within your site, where relative paths are obviously best. Good to hear that you're using the RequestDispatcher for this purpose now. HTH, -Jeff Sullivan, Mark E Mark.Sullivan@nav-internatTo: 'Tomcat Users List' [EMAIL PROTECTED] ional.com cc: Subject: RE: RequestDispatcher forward versus response.sendRedirect 07/24/02 11:13 AM Please respond to Tomcat Users List when you say response.sendRedirect doesn't work, what kind of error/unexpected behavior are you getting? -Original Message- From: Jason Stortz [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:12 AM To: Tomcat Users List Subject: RequestDispatcher forward versus response.sendRedirect Anyone have any hard and fast rules, good links, general info, do and don't lists, or anything about these two? We moved from iPlanet 4.1 where we did all redirection with response.sendRedirect. That didn't work with tomcat so I started using the forward method of RequestDispatcher. Well, now I need to use a NON relative path to redirect the user off our site. While I think response.sendRedirect will work in this instance I cannot seem to formulate a theory why it works here and not in other parts of our site. Does anyone have any information on this I can read, or advice? Thanks! Jason -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: RequestDispatcher forward versus response.sendRedirect
Jeff, Thanks for reply. So, probably always use response.sendRedirect with absolute url to something out of my webapp, but RequestDispatcher for moving to other sources inside my webapp? Does that sound right? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:25 AM To: Tomcat Users List Subject: RE: RequestDispatcher forward versus response.sendRedirect Hi, Jason. I believe that that is precisely the intended use of the response.sendRedirect ... when you are redirecting OFF your site (to an absolute path). The specs say that sendRedirect takes an absolute path, so it is not good to use for forwarding around within your site, where relative paths are obviously best. Good to hear that you're using the RequestDispatcher for this purpose now. HTH, -Jeff Sullivan, Mark E Mark.Sullivan@nav-internatTo: 'Tomcat Users List' [EMAIL PROTECTED] ional.com cc: Subject: RE: RequestDispatcher forward versus response.sendRedirect 07/24/02 11:13 AM Please respond to Tomcat Users List when you say response.sendRedirect doesn't work, what kind of error/unexpected behavior are you getting? -Original Message- From: Jason Stortz [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:12 AM To: Tomcat Users List Subject: RequestDispatcher forward versus response.sendRedirect Anyone have any hard and fast rules, good links, general info, do and don't lists, or anything about these two? We moved from iPlanet 4.1 where we did all redirection with response.sendRedirect. That didn't work with tomcat so I started using the forward method of RequestDispatcher. Well, now I need to use a NON relative path to redirect the user off our site. While I think response.sendRedirect will work in this instance I cannot seem to formulate a theory why it works here and not in other parts of our site. Does anyone have any information on this I can read, or advice? Thanks! Jason -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: RequestDispatcher forward versus response.sendRedirect
As far as I know, it sounds right to me... Jason Stortz jstortz@quoteTo: Tomcat Users List [EMAIL PROTECTED] smith.comcc: Subject: RE: RequestDispatcher forward versus response.sendRedirect 07/24/02 11:29 AM Please respond to Tomcat Users List Jeff, Thanks for reply. So, probably always use response.sendRedirect with absolute url to something out of my webapp, but RequestDispatcher for moving to other sources inside my webapp? Does that sound right? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:25 AM To: Tomcat Users List Subject: RE: RequestDispatcher forward versus response.sendRedirect Hi, Jason. I believe that that is precisely the intended use of the response.sendRedirect ... when you are redirecting OFF your site (to an absolute path). The specs say that sendRedirect takes an absolute path, so it is not good to use for forwarding around within your site, where relative paths are obviously best. Good to hear that you're using the RequestDispatcher for this purpose now. HTH, -Jeff Sullivan, Mark E Mark.Sullivan@nav-internatTo: 'Tomcat Users List' [EMAIL PROTECTED] ional.com cc: Subject: RE: RequestDispatcher forward versus response.sendRedirect 07/24/02 11:13 AM Please respond to Tomcat Users List when you say response.sendRedirect doesn't work, what kind of error/unexpected behavior are you getting? -Original Message- From: Jason Stortz [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 24, 2002 11:12 AM To: Tomcat Users List Subject: RequestDispatcher forward versus response.sendRedirect Anyone have any hard and fast rules, good links, general info, do and don't lists, or anything about these two? We moved from iPlanet 4.1 where we did all redirection with response.sendRedirect. That didn't work with tomcat so I started using the forward method of RequestDispatcher. Well, now I need to use a NON relative path to redirect the user off our site. While I think response.sendRedirect will work in this instance I cannot seem to formulate a theory why it works here and not in other parts of our site. Does anyone have any information on this I can read, or advice? Thanks! Jason -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Check Session is valid response.sendRedirect not working
hi all, I have also encountered the same problem. I am using a login.jsp page, where the user has to enter his login id and password, then while submitting , it calls the servlet class to validate the login and then the servlet sends the response to a new jsp page. In the servlet, i am storing some data in the session. In each jsp, i am getting the session data and after validating, displaying the particular page, based on the data. but, when retreiving the session data, it gives null. i have used response.sendRedirect() to send the response to jsp and session.getAttribute(xVar) to get the session data. and also i have tested using getRequestDispatcher() and application object, but still the issue exist. I had put this issue in JDC forum,jguru forum and javaranch forum, but i couldn't get proper response and answer. I am really wondering, of the fact, i am not getting answers from java , jsp guru's... Is it really, tomcat doesnot support session. The same code working fine using Resin 1.2.5. But when porting to tomcat, it gives such an issue. Can any one please come forward , to conclude this issue. Thanks in advance, Murugan -Original Message- From: Ashish Kulkarni [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 17, 2002 10:01 PM To: Tomcat Users List Subject: Check Session is valid response.sendRedirect not working Hi, I am developing a webapplication with tomcat4.0.4 and apache 2.0.39, I want the user to login on first page, and then check if the session is valid or not in each jsp, and servlet. So what is the best way to do it?? i am using jsp code code as below, but seems it that response.sendRedirect(http://localhost/maps/pages/index.jsp;); does not work. AS400 value = (AS400)session.getAttribute(as400); System.out.println(value of as400 change env + value); if (value == null) { System.out.println(there is no as400 so response.sednRedirect); response.sendRedirect(http://localhost/maps/pages/index.jsp;); System.out.println(i am not able to redirec); } this code works on JRun, Blazix, Websphere, Weblogic so what is the problem Ashish __ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Check Session is valid response.sendRedirect not working
Hi, I am developing a webapplication with tomcat4.0.4 and apache 2.0.39, I want the user to login on first page, and then check if the session is valid or not in each jsp, and servlet. So what is the best way to do it?? i am using jsp code code as below, but seems it that response.sendRedirect(http://localhost/maps/pages/index.jsp;); does not work. AS400 value = (AS400)session.getAttribute(as400); System.out.println(value of as400 change env + value); if (value == null) { System.out.println(there is no as400 so response.sednRedirect); response.sendRedirect(http://localhost/maps/pages/index.jsp;); System.out.println(i am not able to redirec); } this code works on JRun, Blazix, Websphere, Weblogic so what is the problem Ashish __ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Check Session is valid response.sendRedirect not working
use jsp:forward instead of response.sendRedirect(). -Original Message- From: Ashish Kulkarni [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 17, 2002 9:31 AM To: Tomcat Users List Subject: Check Session is valid response.sendRedirect not working Hi, I am developing a webapplication with tomcat4.0.4 and apache 2.0.39, I want the user to login on first page, and then check if the session is valid or not in each jsp, and servlet. So what is the best way to do it?? i am using jsp code code as below, but seems it that response.sendRedirect(http://localhost/maps/pages/index.jsp;); does not work. AS400 value = (AS400)session.getAttribute(as400); System.out.println(value of as400 change env + value); if (value == null) { System.out.println(there is no as400 so response.sednRedirect); response.sendRedirect(http://localhost/maps/pages/index.jsp;); System.out.println(i am not able to redirec); } this code works on JRun, Blazix, Websphere, Weblogic so what is the problem Ashish __ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: response.sendRedirect not redirecting
Thanks a lot, it worked! What does return do? -Original Message- From: Brian Adams [mailto:[EMAIL PROTECTED]] Sent: Sunday, March 17, 2002 8:05 PM To: Tomcat Users List Subject: RE: response.sendRedirect not redirecting add return; just after response.sendR. -Original Message- From: Mostafa Al-Mallawani [mailto:[EMAIL PROTECTED]] Sent: Sunday, March 17, 2002 7:12 AM To: 'Tomcat Users List' Subject: response.sendRedirect not redirecting Hi, I have a problem with redirecting. In my JSP page I keep checking for errors, whenever I catch one, I set a variable on the session object and then forward to an error page; this could happen up to 5 times in one page. The weird thing is, redirection works on some pages and does absolutely nothing on some other pages. Execution just passes over response.sendRedirect(../error.jsp); like it doesn't even exist. Please help, this is really frustrating. Thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 3:45 PM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? The exception seems to be occurring because the Home servlet forwards more than once (to different locations) - first to home.jsp, then later to the Create servlet. It is definitely the fact that it is forwarding to more than one place, that is causing the problem. I know this because if I call the Login servlet and fail the login authorization - this servlet consequently forwards to login.jsp more than once (first - to display the fresh login page, and second - to prompt user to try again). This however does not give me an exception. Given that my Home servlet is like the central servlet, it needs to be capable of forwarding to a variety of places, depending on the activity selected by the user. Ryan - I have looked at create.jsp and, as far as my little mind can see, it does not play with the response object at all. All it does is get a few session attributes and fit them into the page using %= blablabla %. Could that be a problem? This problem is not isolated to the Create example. There are other activities the user can choose which all follow exactly the same forwarding mechanism (except to different servlets), and these give exactly the same exception. Lindsay -Original Message- From: Ryan Daigle [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 13:25 To: 'Tomcat Users List' Subject:RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? Are you sure there isn't something in create.jsp that is trying to manipulate the response? I have found that trying to do a jsp:include... after manipulating the session can cause this exception. Is this a possibility? Perhaps you could send the relevant source of create.jsp and the Create servlet? -Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:26 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? OK here's the sequence of events: [ Note: all forwarding done using RequestDispatcher.forward(req,res) ] 1. User begins by clicking link to Login servlet 2. Login servlet forwards to login.jsp 3. Login.jsp submits request to Login servlet 4. Servlet authorizes user and forwards to Home servlet 5. Home servlet forwards to home.jsp NO EXCEPTIONS YET - EVERYTHING IS OK! 6. User then chooses an action (e.g. create new agent, in my example) from home.jsp and submits request to Home servlet 7. Home servlet processes request and forwards to appropriate servlet (called Create in my example) 8. Create servlet does some stuff and forwards to create.jsp BANG! I GET THIS EXCEPTION (I have included some buildup to this exception): Now in Home servlet - processing request... 2002-03-08 13:19:08 - DecodeInterceptor: Charset from session ISO-8859-1 Now in Create servlet - processing request... Getting list of available types seems to have went OK 2002-03-08 13:19:09 - Ctx(/AgentGenerator) : IllegalStateException in R( /AgentGenerator + /create.jsp + null) - java.la ng.IllegalStateException: Cannot forward because the response has already been committed at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source) at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source) at zeus.generator.web.controllers.Home.goToAddress(Home.java:157) at zeus.generator.web.controllers.Home.processRequest(Home.java:120) at zeus.generator.web.controllers.Home.doGet(Home.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source) at org.apache.tomcat.core.Handler.invoke(Unknown
Re: response.sendRedirect not redirecting
--- Mostafa Al-Mallawani [EMAIL PROTECTED] wrote: Hi, I have a problem with redirecting. In my JSP page I keep checking for errors, whenever I catch one, I set a variable on the session object and then forward to an error page; this could happen up to 5 times in one page. The weird thing is, redirection works on some pages and does absolutely nothing on some other pages. Execution just passes over response.sendRedirect(../error.jsp); like it doesn't even exist. Please help, this is really frustrating. Thanks. I am guessing that this happens because you are calling sendRedirect after writing something to the response that causes it to be committed. Once the servlet container (tomcat) considers the response committed it can start streaming it to the browser, and so at that point it's kind-of too late to change your mind and redirect. Attempting to redirect at this point will cause an IllegalStateException. Maybe your error catching code is eating this exception. Look at the JavaDocs for the Servlet API, specifically HttpServletResponse.sendRedirect() for a clearer explaination. Hope this helps, -Chris __ Do You Yahoo!? Yahoo! Sports - live college hoops coverage http://sports.yahoo.com/ -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
response.sendRedirect not redirecting
Hi, I have a problem with redirecting. In my JSP page I keep checking for errors, whenever I catch one, I set a variable on the session object and then forward to an error page; this could happen up to 5 times in one page. The weird thing is, redirection works on some pages and does absolutely nothing on some other pages. Execution just passes over response.sendRedirect(../error.jsp); like it doesn't even exist. Please help, this is really frustrating. Thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 3:45 PM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? The exception seems to be occurring because the Home servlet forwards more than once (to different locations) - first to home.jsp, then later to the Create servlet. It is definitely the fact that it is forwarding to more than one place, that is causing the problem. I know this because if I call the Login servlet and fail the login authorization - this servlet consequently forwards to login.jsp more than once (first - to display the fresh login page, and second - to prompt user to try again). This however does not give me an exception. Given that my Home servlet is like the central servlet, it needs to be capable of forwarding to a variety of places, depending on the activity selected by the user. Ryan - I have looked at create.jsp and, as far as my little mind can see, it does not play with the response object at all. All it does is get a few session attributes and fit them into the page using %= blablabla %. Could that be a problem? This problem is not isolated to the Create example. There are other activities the user can choose which all follow exactly the same forwarding mechanism (except to different servlets), and these give exactly the same exception. Lindsay -Original Message- From: Ryan Daigle [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 13:25 To: 'Tomcat Users List' Subject:RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? Are you sure there isn't something in create.jsp that is trying to manipulate the response? I have found that trying to do a jsp:include... after manipulating the session can cause this exception. Is this a possibility? Perhaps you could send the relevant source of create.jsp and the Create servlet? -Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:26 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? OK here's the sequence of events: [ Note: all forwarding done using RequestDispatcher.forward(req,res) ] 1. User begins by clicking link to Login servlet 2. Login servlet forwards to login.jsp 3. Login.jsp submits request to Login servlet 4. Servlet authorizes user and forwards to Home servlet 5. Home servlet forwards to home.jsp NO EXCEPTIONS YET - EVERYTHING IS OK! 6. User then chooses an action (e.g. create new agent, in my example) from home.jsp and submits request to Home servlet 7. Home servlet processes request and forwards to appropriate servlet (called Create in my example) 8. Create servlet does some stuff and forwards to create.jsp BANG! I GET THIS EXCEPTION (I have included some buildup to this exception): Now in Home servlet - processing request... 2002-03-08 13:19:08 - DecodeInterceptor: Charset from session ISO-8859-1 Now in Create servlet - processing request... Getting list of available types seems to have went OK 2002-03-08 13:19:09 - Ctx(/AgentGenerator) : IllegalStateException in R( /AgentGenerator + /create.jsp + null) - java.la ng.IllegalStateException: Cannot forward because the response has already been committed at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source) at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source) at zeus.generator.web.controllers.Home.goToAddress(Home.java:157) at zeus.generator.web.controllers.Home.processRequest(Home.java:120) at zeus.generator.web.controllers.Home.doGet(Home.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source) at org.apache.tomcat.core.Handler.invoke(Unknown Source) at org.apache.tomcat.core.Handler.service(Unknown Source) at org.apache.tomcat.facade.ServletHandler.service(Unknown Source) at org.apache.tomcat.core.ContextManager.internalService(Unknown Source) at org.apache.tomcat.core.ContextManager.service(Unknown Source) at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unk nown Source) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown
RE: response.sendRedirect not redirecting
add return; just after response.sendR. -Original Message- From: Mostafa Al-Mallawani [mailto:[EMAIL PROTECTED]] Sent: Sunday, March 17, 2002 7:12 AM To: 'Tomcat Users List' Subject: response.sendRedirect not redirecting Hi, I have a problem with redirecting. In my JSP page I keep checking for errors, whenever I catch one, I set a variable on the session object and then forward to an error page; this could happen up to 5 times in one page. The weird thing is, redirection works on some pages and does absolutely nothing on some other pages. Execution just passes over response.sendRedirect(../error.jsp); like it doesn't even exist. Please help, this is really frustrating. Thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 3:45 PM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? The exception seems to be occurring because the Home servlet forwards more than once (to different locations) - first to home.jsp, then later to the Create servlet. It is definitely the fact that it is forwarding to more than one place, that is causing the problem. I know this because if I call the Login servlet and fail the login authorization - this servlet consequently forwards to login.jsp more than once (first - to display the fresh login page, and second - to prompt user to try again). This however does not give me an exception. Given that my Home servlet is like the central servlet, it needs to be capable of forwarding to a variety of places, depending on the activity selected by the user. Ryan - I have looked at create.jsp and, as far as my little mind can see, it does not play with the response object at all. All it does is get a few session attributes and fit them into the page using %= blablabla %. Could that be a problem? This problem is not isolated to the Create example. There are other activities the user can choose which all follow exactly the same forwarding mechanism (except to different servlets), and these give exactly the same exception. Lindsay -Original Message- From: Ryan Daigle [mailto:[EMAIL PROTECTED]] Sent: 08 March 2002 13:25 To: 'Tomcat Users List' Subject:RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? Are you sure there isn't something in create.jsp that is trying to manipulate the response? I have found that trying to do a jsp:include... after manipulating the session can cause this exception. Is this a possibility? Perhaps you could send the relevant source of create.jsp and the Create servlet? -Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 8:26 AM To: [EMAIL PROTECTED] Subject: RE: How can I resolve this IllegalStateException: Response has a lrea dy been committed problem? OK here's the sequence of events: [ Note: all forwarding done using RequestDispatcher.forward(req,res) ] 1. User begins by clicking link to Login servlet 2. Login servlet forwards to login.jsp 3. Login.jsp submits request to Login servlet 4. Servlet authorizes user and forwards to Home servlet 5. Home servlet forwards to home.jsp NO EXCEPTIONS YET - EVERYTHING IS OK! 6. User then chooses an action (e.g. create new agent, in my example) from home.jsp and submits request to Home servlet 7. Home servlet processes request and forwards to appropriate servlet (called Create in my example) 8. Create servlet does some stuff and forwards to create.jsp BANG! I GET THIS EXCEPTION (I have included some buildup to this exception): Now in Home servlet - processing request... 2002-03-08 13:19:08 - DecodeInterceptor: Charset from session ISO-8859-1 Now in Create servlet - processing request... Getting list of available types seems to have went OK 2002-03-08 13:19:09 - Ctx(/AgentGenerator) : IllegalStateException in R( /AgentGenerator + /create.jsp + null) - java.la ng.IllegalStateException: Cannot forward because the response has already been committed at org.apache.tomcat.facade.RequestDispatcherImpl.doForward(Unknown Source) at org.apache.tomcat.facade.RequestDispatcherImpl.forward(Unknown Source) at zeus.generator.web.controllers.Home.goToAddress(Home.java:157) at zeus.generator.web.controllers.Home.processRequest(Home.java:120) at zeus.generator.web.controllers.Home.doGet(Home.java:131) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source) at org.apache.tomcat.core.Handler.invoke(Unknown Source) at org.apache.tomcat.core.Handler.service(Unknown Source) at org.apache.tomcat.facade.ServletHandler.service(Unknown Source) at org.apache.tomcat.core.ContextManager.internalService(Unknown Source
response.sendRedirect
I have the following code snipet in a .JSP... if (userStatus.equals (Failed)) { session.invalidate() ; // Kill this session. response.sendRedirect(htmlHome) ; // Redirect the user to our home page. return ; } When this condition occurs, the response.sendRedirect fails with the following message: javax.servlet.ServletException: Response has already been committed According to the response object documentation, the sendRedirect 'must be called before the response is committed (in other words, before the status code and headers have been written).' Obviously, the response has been committed, else I wouldn't be getting the error! My question - is the session.invalidate() doing this to me, or is it something else that I am completely unaware of? Thanks. Jerry Jalenak LabOne, Inc. This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
RE: response.sendRedirect
Poking fun have you // your session.invalidate and tried it? :) sorry it begged the question! my answer is dunno, try commenting it out and then try it or swapping the two lines /Poking fun -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 17, 2002 2:26 PM To: '[EMAIL PROTECTED]' Subject: response.sendRedirect I have the following code snipet in a .JSP... if (userStatus.equals (Failed)) { session.invalidate() ; // Kill this session. response.sendRedirect(htmlHome) ; // Redirect the user to our home page. return ; } When this condition occurs, the response.sendRedirect fails with the following message: javax.servlet.ServletException: Response has already been committed According to the response object documentation, the sendRedirect 'must be called before the response is committed (in other words, before the status code and headers have been written).' Obviously, the response has been committed, else I wouldn't be getting the error! My question - is the session.invalidate() doing this to me, or is it something else that I am completely unaware of? Thanks. Jerry Jalenak LabOne, Inc. This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
RE: response.sendRedirect
Yeah, I have. I'm also getting it now outside of the snipnet, when I am just wanting to redirect to another page. Should I be using jsp:forward instead? Jerry -Original Message- From: Brian Adams [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 17, 2002 2:08 PM To: 'Tomcat Users List' Subject: RE: response.sendRedirect Poking fun have you // your session.invalidate and tried it? :) sorry it begged the question! my answer is dunno, try commenting it out and then try it or swapping the two lines /Poking fun -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 17, 2002 2:26 PM To: '[EMAIL PROTECTED]' Subject: response.sendRedirect I have the following code snipet in a .JSP... if (userStatus.equals (Failed)) { session.invalidate() ; // Kill this session. response.sendRedirect(htmlHome) ; // Redirect the user to our home page. return ; } When this condition occurs, the response.sendRedirect fails with the following message: javax.servlet.ServletException: Response has already been committed According to the response object documentation, the sendRedirect 'must be called before the response is committed (in other words, before the status code and headers have been written).' Obviously, the response has been committed, else I wouldn't be getting the error! My question - is the session.invalidate() doing this to me, or is it something else that I am completely unaware of? Thanks. Jerry Jalenak LabOne, Inc. This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
RE: response.sendRedirect
Do you have any html tags in your jsp file before the logic you mention? Also, what jsp spec are you using? -Original Message- From: Jerry Jalenak [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 17, 2002 3:26 PM To: '[EMAIL PROTECTED]' Subject: response.sendRedirect I have the following code snipet in a .JSP... if (userStatus.equals (Failed)) { session.invalidate() ; // Kill this session. response.sendRedirect(htmlHome) ; // Redirect the user to our home page. return ; } When this condition occurs, the response.sendRedirect fails with the following message: javax.servlet.ServletException: Response has already been committed According to the response object documentation, the sendRedirect 'must be called before the response is committed (in other words, before the status code and headers have been written).' Obviously, the response has been committed, else I wouldn't be getting the error! My question - is the session.invalidate() doing this to me, or is it something else that I am completely unaware of? Thanks. Jerry Jalenak LabOne, Inc. This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at (800)388-4675. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Tomcat and Ultradev produced pages. response.sendRedirect problem.
Hi, We have several customers using Ultradev to produce jsp for their site, everything seems fine, especially if you use non IE browsers. However for response.redirect we get either, the original page after a submission then some garbled cache type data and then the correct destination page. Or for simple links you occasionally get the strange cache data. It looks like this: HTTP/1.1 200 Date: Tue, 11 Sep 2001 16:31:26 GMT Server: Apache Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 a4e I know how to massage to the jsp to stop this, with the original line commented out: response.setStatus( 301 ); response.setHeader( Location, MM_editRedirectUrl ); response.flushBuffer(); //response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl)); However massaging UltraDevs code all the time is not really practical! :) My question is what causes this behaviour? I presume the other browsers never display it, or display correctly because they don't show anything until the html or Content-Type: label. So seeing as we cannot alter Ultradevs behaviour and we definately cant alter IE's how do I get tomcat stop this? With our previous servlet runners i never experienced this. *phew* Long post Thanks if you made it this far. Paul
RE: Tomcat and Ultradev produced pages. response.sendRedirect problem.
Actually you can alter and wildly extend the behaviour (and develop plug-in type new functionality) from that which ships with Ultradev, I suggest you look in on http://www.macromedia.com/support/dreamweaver/extend/form/ where you can sign up for a closed news group where you'll get good advice, also look at the extending ultradev manual. -Original Message- From: Paul Downs [mailto:[EMAIL PROTECTED]] Hi, We have several customers using Ultradev everything seems fine However you occasionally get strange data.
RE: Tomcat and Ultradev produced pages. response.sendRedirect problem.
The code that Ultradev produces has a couple of problems. First, there is a CR-LF which is taken as HTML between the first and second lines. Emitting HTML will most likely cause default HTML headers to be issued. Second, there is NO return; after the redirect, so the program continues on its merry way producing the HTML that is supposed to be stopped. Add return; after the redirect. Close up the CR-LFs between % and %, putting the spaces in the java where they are relatively harmless. Otherwise you have a race condition between the headers and the HTML with unreliable results, not even reliable failure. EXAMPLE: %@page contentType=text/html; charset=iso-8859-1 language=java import=java.sql.*% % ... response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL)); } % // no return;, so code here is executed. -Original Message- From: Paul Downs [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 19, 2001 9:38 AM To: tomcat Subject: Tomcat and Ultradev produced pages. response.sendRedirect problem. Hi, We have several customers using Ultradev to produce jsp for their site, everything seems fine, especially if you use non IE browsers. However for response.redirect we get either, the original page after a submission then some garbled cache type data and then the correct destination page. Or for simple links you occasionally get the strange cache data. It looks like this: HTTP/1.1 200 Date: Tue, 11 Sep 2001 16:31:26 GMT Server: Apache Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 a4e I know how to massage to the jsp to stop this, with the original line commented out: response.setStatus( 301 ); response.setHeader( Location, MM_editRedirectUrl ); response.flushBuffer(); //response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl)); However massaging UltraDevs code all the time is not really practical! :) My question is what causes this behaviour? I presume the other browsers never display it, or display correctly because they don't show anything until the html or Content-Type: label. So seeing as we cannot alter Ultradevs behaviour and we definately cant alter IE's how do I get tomcat stop this? With our previous servlet runners i never experienced this. *phew* Long post Thanks if you made it this far. Paul
response.sendRedirect problems with IE5.5
When I call the response.sendRedirect() function from a Java Bean I get a response that already has data in it, the only problem is that the response shouldn't have any data in it already. I have a function call before anything is written to the output buffer that determines if this page should call a response.sendRedirect(). The weird thing is that only IE has the data that shouldn't be returned in the html page (from the view source option). Netscape doesn't have the garbage data when I view source. What is going on here? Info: Tomcat 3.2.3 jdk1.2.2 NT 4.0 ### data that shouldn't be returned ### !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN http://www.w3.org/TR/REC-html40/loose.dtd; html head ... omitted data ... CircImage4.src = HTTP/1.1 200 OK Via: 1.0 MAIL Connection: Keep-Alive Content-Length: 1536 Content-Type: text/html Last-Modified: Thu, 16 Aug 2001 16:54:28 GMT Servlet-Engine: Tomcat Web Server/3.2.3 (JSP 1.1; Servlet 2.2; Java 1.2.2; Windows NT 4.0 x86; java.vendor=Sun Microsystems Inc.) ### page that should be returned ### html head ... rest of response ... ### relevent parts of index. jsp ### /*** session operations ***/ try { sessionBean.setResponse(response); sessionBean.setRequest(request); sessionBean.setIP(request.getRemoteAddr()); sessionBean.setFile(path + name); sessionBean.log(); } catch(IOException ignored) { } catch(SQLException ignored) { } // output header,nav application.getRequestDispatcher(/main.jsp).include(request,response); // output static page if no processing needed on content if(proc == null || proc.equals(false)) { application.getRequestDispatcher(/static.jsp).include(request,response); } else { application.getRequestDispatcher(/ + name).include(request,response); } // output footer application.getRequestDispatcher(/footer.jsp).include(request,response); % ### relevent portion of SessionBean ### public void log() { ... if(visits == 1) { res.sendRedirect(/intro.html); } ... }