Chris,
We do the same thing in our action classes in order to avoid the page
refresh problem. However, we use the DynamicURI class directly, instead of
using the TemplateLink class. I did not take the time to see what the
differences are, but take a look at the following code and see if it helps.
It is similar to the redirect code in Turbine.java, but we use
addQueryData() for the parameters instead of addPathInfo() because we seem
to having trouble with that approach (a separate unrelated issue).
Kevin
...
// redirect to the same template, but without the action parameter
DynamicURI duri = new DynamicURI (data, true);
// pass on selected request parameters.
for (Enumeration e = data.getParameters().keys(); e.hasMoreElements(); )
{
String key = (String) e.nextElement();
// Pass on all parameters except the action.
if (!key.equalsIgnoreCase("action"))
{
String value = (String) data.getParameters().getString(key);
if (value != null && value.length() > 0)
{
duri.addQueryData((String)key, (String)value);
}
}
}
data.getResponse().sendRedirect(duri.toString());
...
> -----Original Message-----
> From: Chris Holman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 28, 2001 4:05 AM
> To: Turbine User
> Subject: Turbine Exceptions after a Redirect in an Action
>
>
> I have been using Turbine for a couple of months now.
> I've been very impressed at the speed at which applications can be put
> together.
>
> Able to get round most problems using the archived mailing
> lists, but this
> ones stumped me.
>
> We are writing a doc management system. We use an Action to save the
> uploaded file data and then use a re-direct to get round the
> problem of page
> refresh reloading that document as a new document.
>
> This seems to work fine as far as the upload is concerned,
> but we are seeing
> a TurbineException(See 'turbine.log' below) as turbine tries
> to decode the
> redirected request. As far as I understand it, it is trying
> to find the
> previously uploaded document(which isn't there after the
> redirect) due to
> the http header still indicating a file upload.
>
> After the TurbineException, the page seems to be redirected again but
> renders correctly the second time. Is this to do with the
> redirect handling
> code in the turbine.java Servlet?
>
> Do I need to change anything in the response?(See 'Redirect
> Code' below)
>
> PS: I noticed that counters have been suggested as one
> solution to the page
> refresh issue, but a page re-direct is a quicker solution for us, if a
> little dirty.
>
> Regards,
> Chris
>
> ************** Start Redirect Code ************
> TemplateLink tl = new TemplateLink( data );
> tl.setPage( "MySecureScreen.vm" ).addPathInfo( "identifier",
> docObj.getDocID() );
> data.setRedirectURI( tl.getURI() );
> data.setStatusCode( 302 );
> // data.setContentType("text/html") //doesnt seem to work.
> ************** End Redirect Code ************
>
>
> ************** Start turbine.log ***************************
> Exception: org.apache.turbine.util.TurbineException: File
> upload failed:
> the request was rejected because it's size is unknown
> Stack Trace follows:
> org.apache.turbine.util.TurbineException: the request was
> rejected because
> it's size is unknown
> at
> org.apache.turbine.services.upload.TurbineUploadService.parseR
> equest(Turbine
> UploadService.java:123)
> at
> org.apache.turbine.services.upload.TurbineUpload.parseRequest(
> TurbineUpload.
> java:178)
> at
> org.apache.turbine.util.parser.DefaultParameterParser.setReque
> st(DefaultPara
> meterParser.java:189)
> rethrown as org.apache.turbine.util.TurbineException: File
> upload failed:
> the request was rejected because it's size is unknown
> at
> org.apache.turbine.util.parser.DefaultParameterParser.setReque
> st(DefaultPara
> meterParser.java:193)
> at
> org.apache.turbine.services.rundata.DefaultTurbineRunData.getP
> arameters(Defa
> ultTurbineRunData.java:502)
> at org.apache.turbine.Turbine.doGet(Turbine.java:278)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilt
> er(Application
> FilterChain.java:247)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
> cationFilterCh
> ain.java:193)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardW
> rapperValve.ja
> va:255)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardC
> ontextValve.ja
> va:225)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 66)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Aut
> henticatorBase
> .java:472)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardContext.invoke(StandardContex
> t.java:2252)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHost
> Valve.java:164
> )
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 66)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValv
> e.java:446)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 64)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEn
> gineValve.java
> :163)
> at
> org.apache.catalina.core.StandardPipeline.invokeNext(StandardP
> ipeline.java:5
> 66)
> at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipel
> ine.java:472)
> at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
> at
> org.apache.catalina.connector.http.HttpProcessor.process(HttpP
> rocessor.java:
> 875)
> at
> org.apache.catalina.connector.http.HttpProcessor.run(HttpProce
> ssor.java:952)
> at java.lang.Thread.run(Thread.java:484)
>
> ************** Start Turbine.log ***************************
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>