>From looking at the Turbine source code, I came to the conclusion that the "correct" way to do a 302 redirect is to use method #2 below. We were using method #1, but after digging through the Turbine source code, it appears that there are some problems with that method.
If you call sendRedirect() yourself, it may send the appropriate redirect information back to the browser, but it appears that Turbine continues to process the original request because you have not told it not to. So it will continue to try to build and send the original page (I think). It may be that the browser handles this OK by doing the redirect and dropping the original connection before the original page gets rendered. But besides being a waste of processing, it seems like there could be other bad effects from this. Many people have reported problems using method #2. It looks like Turbine.java only checks to see if you want to do a redirect if you have not already sent some output. Basically, if you (or some part of the page building process) calls the RunData.getOut() method, a flag is set and Turbine will not even check to see if you are trying to do a redirect. Perhaps that is related to the problems people are having. I don't claim to understand it all, so perhaps one of the Turbine developers can shed more light on this issue ?? Kevin > -----Original Message----- > From: Gary Bisaga [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 10:21 AM > To: Turbine Users List > Subject: RE: TemplateScreen.doRedirect() > > > Hmmm... it seems there are two different ways of doing > basically the same > thing: > 1. Darren's current way: > RunData.declareDirectResponse() > RunData.getResponse().sendRedirect() > 2. Building on Darren's previous way, I am doing this: > RunData.setRedirectURI() > RunData.setStatusCode() > In your layout class (replacing VelocityOnlyTemplate), don't call > getOut() > to generate output at the end, just return if a redirect > URI is set. > > Both of them seem to work; but #2 seems to be the one supported by the > Turbine > servlet itself, if I am understanding the code correctly. So, which is > preferable? Are they intended to be used in different ways, > and if so when? > > Vobis gratias ago, > <>< gary > > -----Original Message----- > From: Darren Gilroy [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 11:23 AM > To: 'Turbine Users List' > Subject: RE: TemplateScreen.doRedirect() > > > I solved this with > > RunData.declareDirectResponse() > RunData.getResponse().sendRedirect() > > FYI & Thanks > -best-darr- > > -----Original Message----- > From: Darren Gilroy [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 07, 2002 7:35 AM > To: 'Turbine Users List' > Subject: RE: TemplateScreen.doRedirect() > > Gary - > > Hey, I'm having trouble with RunData.setRedirectURI() -- I'm calling > RunData.setStatusCode() as directed, and I am getting a 302 > response, but > not with the URL that I specified in setRedirectURI. I get > http://localhost:8180/app/servlet/app/tempalte/file.vm/x/2/red > irected/true?j > sessionid= ... > > I am calling the setRedirectURI from a screen class that is > extended from > VelocitySecureScreen, in the doBuildTemplate() method. Is > that not a legal > place to call this method? It is necessary to move it to an action or > something? > > Thanks! > -best-darr- > > -----Original Message----- > From: Gary Bisaga [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 06, 2002 3:19 PM > To: Turbine Users List > Subject: RE: TemplateScreen.doRedirect() > > Dazza- found the answer. Look at TemplatePage - the > doBuildAfterAction uses > TurbineTemplate converts the template name to a screen name > if no screen > name is given. But is this really what you want to do? > > Seems like though, upon further reflection, you might want to > start the page > all over again (e.g. to give you a chance to change the > layout etc.) and so > to do a real redirect (data.setRedirectURI). What's more, > usually in these > kinds of situations I've found that a real redirect is safer > because the > browser's URL line is now correct: instead of showing the old, > redirected-from URL, it will show the new, redirected-to one. > > <>< gary > > -----Original Message----- > From: Darren Gilroy [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 06, 2002 4:22 PM > To: Turbine Users List > Subject: TemplateScreen.doRedirect() > > > Hi - > > I'm calling doRedirect() from my screen class, and It's not > working how I > expected. I hope somebody can adjust my expectations. > > I expected doRedirect( data, templateName ) to load and run > the screen class > that it would run if you called the template with > /app/servlet/app/template/something.vm > > I see a doRedirect( data, screenName, templateName ) - How > can I look up the > screenName to use based on the templateName, using the same logic that > Turbine normally does? > > Or, do you recommend a data.setRedirectURI() instead? Or > something else? > > Thanks! > -best-darr- > > > -- > 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]>
