One idea for the magicMethod: (Just PseudoCode has never seen a
compiler)

synchronized (session) {
  String mMagicSessionToken = session.get("MagicToken");
  String mMagicRequestToken = request.getParameter("MagicToken");  
  String mRandom = <GetRandomNumber>.toString();

  if ((mMagicSessionToken != null) && (!
mMagicSessionToken.equals(mMagicRequestToken))) {
     // resubmit of the same page
     // do what ever you want, when this happens
     return; // throw new SomeException()
   }
   session.put("MagicToken", mRandom);
}
// create links or forms with MagicToken=<mRandom>

That's not the complete solution, but I hope you get the idea.

> -----Ursprungliche Nachricht-----
> Von: Jenya Strokin [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 18. Juli 2002 18:10
> An: Tomcat Users List
> Betreff: RE: How to close a response?
> 
> 
> Guys...... it works now, but I don't understand why)))
> I change code to synchronize the sharedSassionBean and didn't 
> put any magic
> methods for checking, and Servlet never send the same data twice. But
> process still running two times. So I still need to write 
> this magic method.
> Thanks for suggestions and help,
> Jenya
> 
> -----Original Message-----
> From: Tim Funk [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 18, 2002 11:25 AM
> To: Tomcat Users List
> Subject: Re: How to close a response?
> 
> 
> There is no need to synchronize the request object. It will 
> not be used
> in multiple threads concurrently. What you really need is
> synchronization of the session to prevent processing of the "double
> submit". If the user submits twice, then 2 different requests may be
> executed in different threads. Closing response streams don't help the
> main goal of preventing the double submit.
> 
> This may be an alternative:
>       synchronized(sharedSessionBean){
>         if (magicMethodToCheckForDoubleProcessingYouNeedToWrite()){
>           abstractBean.setSharedSession(sharedSessionBean);
>           abstractBean.setRequest(request);
>           abstractBean.setResponse(response);
>           abstractBean.setServlet(this);
>           abstractBean.process();
>           abstractBean.footerProcess();
>         } else {
>           //goto double submit error page
>         }
>       }
> 
> -Tim
> 
> Jenya Strokin wrote:
> > I'm using servlet. But if you know way how to do this from 
> JSP, please
> share
> > it.))
> > This is my method wich called from doGet and doPost:
> >
> >   public void doGetPost(HttpServletRequest request, 
> HttpServletResponse
> > response)
> >   throws ServletException, IOException {
> > /*------------------------------------------------------
> > If user clicks link twice, browser will get the same screen 
> two times
> mixed.
> > So, I need synchronized processes. But after that browser 
> will get the
> same
> > screen one after another. So I need close output after I 
> process first
> > request, and second request can not write to output string.
> > --------------------------------------------------------*/
> >
> >     synchronized(request){
> >       abstractBean.setSharedSession(sharedSessionBean);
> >       abstractBean.setRequest(request);
> >       abstractBean.setResponse(response);
> >       abstractBean.setServlet(this);
> >       abstractBean.process();
> >
> >       abstractBean.footerProcess();
> > //---------- I'm trying to close output here, but second 
> process write its
> > data anyway
> > //      out.close();
> >       response.getWriter().close();
> >     }
> >   }
> >
> > If this information is not enough, I'll provide more.
> > Thanks for any help.
> >
> > -----Original Message-----
> > From: Durham David Cntr 805CSS/SCBE 
> [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, July 18, 2002 10:18 AM
> > To: Tomcat Users List
> > Subject: RE: How to close a response?
> >
> >
> > Need more detail about your problem.  Are you having a 
> problem with JSP?
> >
> > -----Original Message-----
> > From: Jenya Strokin [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, July 18, 2002 9:17 AM
> > To: [EMAIL PROTECTED]
> > Subject: How to close a response?
> >
> >
> > Hi,
> > I need to close the response completely. In some case I 
> need to avoid any
> > process write to response output.
> > Using
> > response.getOutputStream().close();
> > response.getWriter().close();
> > response.reset();
> > do not help.
> > Thanks for any suggestions.
> >
> > Jenya
> >
> > -------------------------------------------
> > Introducing NetZero Long Distance
> > Unlimited Long Distance only $29.95/ month!
> > Sign Up Today! www.netzerolongdistance.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]>
> >
> >
> > -------------------------------------------
> > Introducing NetZero Long Distance
> > Unlimited Long Distance only $29.95/ month!
> > Sign Up Today! www.netzerolongdistance.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]>
> 
> 
> -------------------------------------------
> Introducing NetZero Long Distance
> Unlimited Long Distance only $29.95/ month!
> Sign Up Today! www.netzerolongdistance.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]>

Reply via email to