You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Shawn Church <sh...@boxity.com> on 2002/07/02 19:17:06 UTC

Form upload failure

Does anyone know of any limitations or problems with Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of template, whose form action is to invoke a servlet which then does nothing except return the same template (which made the request) to Velocity, I am getting this from Apache:

HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24 (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 

This problem occurs if I select a file for upload, or if I do not select anything but rather just resubmit the form a few times in rapid succession.  If I do not select a file, and submit the form no more often than once per every couple of seconds, the problem does not occur.

Here is a test template:

<html>
<form action="/ec/servlet/upload" method="post" enctype="multipart/form-data">
  Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
<input type=submit>
</form>
</html>


Here's a snippet of the upload servlet, which is coded to do nothing except return the same form which made the request:

...
public class upload extends VelocityServlet
{
 public Template handleRequest( HttpServletRequest _req, HttpServletResponse _res, Context _context)
 {
  String templateName = "upload.vm";
 
  // return the appropriate template
  try 
  {
   return getTemplate(templateName);
    } 
    catch (Exception e) 
    {
   
  }

  return null;
 }
... 

My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0, running on Win2k.  If my servlet returns a different template than the one which made the request, everything is fine.

Shawn


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
A couple more things.  Even though on the browser page Apache seemed to
report a 200, in the access log I see a 200 for the initial presentation of
the form, but the submit results in a 500 like in IIS.  The 200 text which
displays on the browser page is apparenty "left-over" from the initial form,
with the "internal error" displayed below actually indicating the 500.

I tried turning off keep-alive in Apache, and I've also tried forcing to
HTTP1.0, but neither of these made any difference.  Is it possible Velocity
is closing the connection? (I don't think so).

Shawn

----- Original Message -----
From: "Shawn Church" <sh...@boxity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Wednesday, July 03, 2002 10:44 AM
Subject: Re: Form upload failure


> After more testing, I realize that the problem actually did not go away
with
> IIS, but IIS handles the exception differently than Apache.  Apache
results
> in an http 200, along with the complaint that "The server encountered an
> internal error or misconfiguration and was unable to complete your
request".
> IIS results in an http 500, page cannot be displayed.  Again, the problem
is
> intermittent but can be easily produced by quickly resubmitting the form.
>
> Eliminating Velocity from the mix seems to also eliminate the problem.
> Using a plain html page with the same type of form, handled by a normal
> HttpServlet, everything works smoothly.  Tomcat is still involved here, so
> the only thing I can think of to do now is to begin tracing through
Velocity
> code to see if anything might somehow relate to <input type=file>.
>
> Thanks for everyone's input,
> Shawn
>
>
> ----- Original Message -----
> From: "Shawn Church" <sh...@boxity.com>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 4:47 PM
> Subject: Re: Form upload failure
>
>
> > FYI, I moved everything to IIS 5 and the problem went away.  However, I
> > really do not want to run this app on IIS because I plan on moving it to
a
> > Linux box for production.  I can move to Tomcat 4 if no one can
reproduce
> > the problem there.
> >
> >
> > Kevin,
> >
> > The last code I sent was not a snippet.  Everything is stripped out for
> this
> > test, so there is only a single servlet and a single template.  There
are
> no
> > globally-scoped objects in this code.
> >
> > I should mention also that I have several other production servers
running
> > both WebMacro (because Velocity didn't exist at the time they were
> > developed), and Velocity, which are perfectly stable under continuous
> usage,
> > so I am fairly confident this is unfortunately an issue with <input
> > type=file>.
> >
> > Shawn
> >
> > ----- Original Message -----
> > From: "Kevin Baynes" <kb...@seagullsw.com>
> > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > Sent: Tuesday, July 02, 2002 3:44 PM
> > Subject: RE: Form upload failure
> >
> >
> > >
> > > Shawn-
> > >
> > > I couldn't tell from the code snippet you sent whether my suspicion is
> > > correct.
> > >
> > > Look for any objects of global scope in the Servlet (ones that are
> outside
> > > of the scope of the methods), that are then modified or accessed
within
> > the
> > > methods. This is an easy thing to let happen within a Servlet, but it
> > yields
> > > unpredictable behavior as an object is modified by one method while
> > another
> > > is still using it.
> > >
> > > I'd have to see the entire file to make sure, but it could be your
> > problem.
> > > You can also test this way: If all your action happens inside of
> > > handleRequest, you can add the "synchronized" keyword to the method
> > > declaration, that will prevent two threads from accessing the method
at
> > the
> > > same time. Declare it synchronized and see if your problem goes
away...
> > then
> > > fix it, don't leave it synchronized.
> > >
> > > ~kevin
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Shawn Church [mailto:shawn@boxity.com]
> > > > Sent: Tuesday, July 02, 2002 3:52 PM
> > > > To: Velocity Users List
> > > > Subject: Re: Form upload failure
> > > >
> > > >
> > > > Nick,
> > > >
> > > > I believe Velocity is getting called, because if I submit the
> > > > form multiple
> > > > times, but delay 2-3 seconds between submissions, I don't see a
> failure.
> > > > Also, once in a while the template gets rendered in the browser,
> > > > followed by
> > > > the (same) error message, so it seems Velocity is happy but
> > > > Apache / Tomcat
> > > > doesn't like the response.
> > > >
> > > > Thanks,
> > > > Shawn
> > > >
> > > > ----- Original Message -----
> > > > From: "Nick Temple" <nt...@alivecity.com>
> > > > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > > > Sent: Tuesday, July 02, 2002 2:26 PM
> > > > Subject: RE: Form upload failure
> > > >
> > > >
> > > > > Hi Shawn --
> > > > >
> > > > > I tend to agree with you.  I do know that uploaded files are a
> little
> > > > > messier to deal with, however since you aren't actually using the
> > > > paramaters
> > > > > I don't see how that could be a problem.
> > > > >
> > > > > I am curious to see where in the code it actually stops
> > > > processing.  Does
> > > > > Velocity even get called? Is the output thrown away by the
> > > > server engine?
> > > > > Anyway, I'm grasping at straws.
> > > > >
> > > > > Give me a couple of hours and I will get a version running on
apache
> > > > 1.3.26
> > > > > / tomcat 4 and see if I can reproduce it.
> > > > >
> > > > > Nick
> > > > >
> > > > > -----Original Message-----
> > > > > From:
> > velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
> > > > >
> > [mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
> > > > > rg]On Behalf Of Shawn Church
> > > > > Sent: Tuesday, July 02, 2002 2:14 PM
> > > > > To: Velocity Users List
> > > > > Subject: Re: Form upload failure
> > > > >
> > > > >
> > > > > Nick,
> > > > >
> > > > > I am using the same thing in my real code, but for the sake of the
> > > > isolation
> > > > > test I have removed it.  The problem is not related to the actual
> > upload
> > > > > code or any of the com.oreilly package, since I'm not getting that
> far
> > > > > unless I work around the problem at hand by returning a
> > > > different template
> > > > > (than the one which made the request) to Velocity.  My test code
> only
> > > > > involves the single template and the single servlet.  To rule out
> > Apache
> > > > and
> > > > > mod_jk, I may try to get it running with IIS (or with Tomcat's web
> > > > server).
> > > > >
> > > > > I added the System.err.println(e.toString()), but it logs no
> > exceptions.
> > > > >
> > > > > Shawn
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Nick Temple" <nt...@alivecity.com>
> > > > > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > > > > Sent: Tuesday, July 02, 2002 1:11 PM
> > > > > Subject: RE: Form upload failure
> > > > >
> > > > >
> > > > > > Here is the system I am using to handle file-uploads:
> > > > > >
> > > > > > http://www.servlets.com/cos/index.html
> > > > > >
> > > > > > However, if the system doesn't hang when POSTing to a different
> > > > > > form/servlet, I tend to think that it isn't the POST at all
rather
> > > > > > "something" in the code.
> > > > > >
> > > > > > Try writing some code in your try / except clause to see if
> > > > an error is
> > > > > > being thrown and ignored (and any places the servlet might be
> > throwing
> > > > an
> > > > > > exception).
> > > > > >
> > > > > >   try
> > > > > >   {
> > > > > >    return getTemplate(templateName);
> > > > > >   }
> > > > > >   catch (Exception e)
> > > > > >   {
> > > > > >     System.err.println(e.toString());
> > > > > >   }
> > > > > >
> > > > > > Nick
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From:
> > > > velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> > > > > >
> > > >
> [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> > > > > > rg]On Behalf Of Björn
> > > > > > Sent: Tuesday, July 02, 2002 12:58 PM
> > > > > > To: Velocity Users List
> > > > > > Subject: Re: Form upload failure
> > > > > >
> > > > > >
> > > > > > Do not know if this might be of any help to you...
> > > > > >
> > > > > > http://www.orionsupport.com/articles/fileupload.html
> > > > > >
> > > > > > It did help me once =)
> > > > > >
> > > > > >
> > > > > > /Björn
> > > > > > ----- Original Message -----
> > > > > > From: "Shawn Church" <sh...@boxity.com>
> > > > > > To: <ve...@jakarta.apache.org>
> > > > > > Sent: Tuesday, July 02, 2002 7:17 PM
> > > > > > Subject: Form upload failure
> > > > > >
> > > > > >
> > > > > > Does anyone know of any limitations or problems with Velocity
1.2
> /
> > > > Apache
> > > > > > 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
> > > > containing
> > > > > > <INPUT TYPE=FILE> ?  Specifically in the case where I have
> > > > this type of
> > > > > > template, whose form action is to invoke a servlet which then
does
> > > > nothing
> > > > > > except return the same template (which made the request) to
> > > > Velocity, I
> > > > am
> > > > > > getting this from Apache:
> > > > > >
> > > > > > HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
> > > > Apache/1.3.24
> > > > > > (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding:
chunked
> > > > > > Content-Type: text/html; charset=iso-8859-1
> > > > > >
> > > > > > This problem occurs if I select a file for upload, or if I do
> > > > not select
> > > > > > anything but rather just resubmit the form a few times in rapid
> > > > > succession.
> > > > > > If I do not select a file, and submit the form no more often
than
> > once
> > > > per
> > > > > > every couple of seconds, the problem does not occur.
> > > > > >
> > > > > > Here is a test template:
> > > > > >
> > > > > > <html>
> > > > > > <form action="/ec/servlet/upload" method="post"
> > > > > > enctype="multipart/form-data">
> > > > > >   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> > > > > > <input type=submit>
> > > > > > </form>
> > > > > > </html>
> > > > > >
> > > > > >
> > > > > > Here's a snippet of the upload servlet, which is coded to do
> nothing
> > > > > except
> > > > > > return the same form which made the request:
> > > > > >
> > > > > > ...
> > > > > > public class upload extends VelocityServlet
> > > > > > {
> > > > > >  public Template handleRequest( HttpServletRequest _req,
> > > > > HttpServletResponse
> > > > > > _res, Context _context)
> > > > > >  {
> > > > > >   String templateName = "upload.vm";
> > > > > >
> > > > > >   // return the appropriate template
> > > > > >   try
> > > > > >   {
> > > > > >    return getTemplate(templateName);
> > > > > >     }
> > > > > >     catch (Exception e)
> > > > > >     {
> > > > > >
> > > > > >   }
> > > > > >
> > > > > >   return null;
> > > > > >  }
> > > > > > ...
> > > > > >
> > > > > > My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE
> > 6.0,
> > > > > > running on Win2k.  If my servlet returns a different template
than
> > the
> > > > one
> > > > > > which made the request, everything is fine.
> > > > > >
> > > > > > Shawn
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > > > <ma...@jakarta.apache.org>
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
After more testing, I realize that the problem actually did not go away with
IIS, but IIS handles the exception differently than Apache.  Apache results
in an http 200, along with the complaint that "The server encountered an
internal error or misconfiguration and was unable to complete your request".
IIS results in an http 500, page cannot be displayed.  Again, the problem is
intermittent but can be easily produced by quickly resubmitting the form.

Eliminating Velocity from the mix seems to also eliminate the problem.
Using a plain html page with the same type of form, handled by a normal
HttpServlet, everything works smoothly.  Tomcat is still involved here, so
the only thing I can think of to do now is to begin tracing through Velocity
code to see if anything might somehow relate to <input type=file>.

Thanks for everyone's input,
Shawn


----- Original Message -----
From: "Shawn Church" <sh...@boxity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 4:47 PM
Subject: Re: Form upload failure


> FYI, I moved everything to IIS 5 and the problem went away.  However, I
> really do not want to run this app on IIS because I plan on moving it to a
> Linux box for production.  I can move to Tomcat 4 if no one can reproduce
> the problem there.
>
>
> Kevin,
>
> The last code I sent was not a snippet.  Everything is stripped out for
this
> test, so there is only a single servlet and a single template.  There are
no
> globally-scoped objects in this code.
>
> I should mention also that I have several other production servers running
> both WebMacro (because Velocity didn't exist at the time they were
> developed), and Velocity, which are perfectly stable under continuous
usage,
> so I am fairly confident this is unfortunately an issue with <input
> type=file>.
>
> Shawn
>
> ----- Original Message -----
> From: "Kevin Baynes" <kb...@seagullsw.com>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 3:44 PM
> Subject: RE: Form upload failure
>
>
> >
> > Shawn-
> >
> > I couldn't tell from the code snippet you sent whether my suspicion is
> > correct.
> >
> > Look for any objects of global scope in the Servlet (ones that are
outside
> > of the scope of the methods), that are then modified or accessed within
> the
> > methods. This is an easy thing to let happen within a Servlet, but it
> yields
> > unpredictable behavior as an object is modified by one method while
> another
> > is still using it.
> >
> > I'd have to see the entire file to make sure, but it could be your
> problem.
> > You can also test this way: If all your action happens inside of
> > handleRequest, you can add the "synchronized" keyword to the method
> > declaration, that will prevent two threads from accessing the method at
> the
> > same time. Declare it synchronized and see if your problem goes away...
> then
> > fix it, don't leave it synchronized.
> >
> > ~kevin
> >
> >
> >
> > > -----Original Message-----
> > > From: Shawn Church [mailto:shawn@boxity.com]
> > > Sent: Tuesday, July 02, 2002 3:52 PM
> > > To: Velocity Users List
> > > Subject: Re: Form upload failure
> > >
> > >
> > > Nick,
> > >
> > > I believe Velocity is getting called, because if I submit the
> > > form multiple
> > > times, but delay 2-3 seconds between submissions, I don't see a
failure.
> > > Also, once in a while the template gets rendered in the browser,
> > > followed by
> > > the (same) error message, so it seems Velocity is happy but
> > > Apache / Tomcat
> > > doesn't like the response.
> > >
> > > Thanks,
> > > Shawn
> > >
> > > ----- Original Message -----
> > > From: "Nick Temple" <nt...@alivecity.com>
> > > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > > Sent: Tuesday, July 02, 2002 2:26 PM
> > > Subject: RE: Form upload failure
> > >
> > >
> > > > Hi Shawn --
> > > >
> > > > I tend to agree with you.  I do know that uploaded files are a
little
> > > > messier to deal with, however since you aren't actually using the
> > > paramaters
> > > > I don't see how that could be a problem.
> > > >
> > > > I am curious to see where in the code it actually stops
> > > processing.  Does
> > > > Velocity even get called? Is the output thrown away by the
> > > server engine?
> > > > Anyway, I'm grasping at straws.
> > > >
> > > > Give me a couple of hours and I will get a version running on apache
> > > 1.3.26
> > > > / tomcat 4 and see if I can reproduce it.
> > > >
> > > > Nick
> > > >
> > > > -----Original Message-----
> > > > From:
> velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
> > > >
> [mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
> > > > rg]On Behalf Of Shawn Church
> > > > Sent: Tuesday, July 02, 2002 2:14 PM
> > > > To: Velocity Users List
> > > > Subject: Re: Form upload failure
> > > >
> > > >
> > > > Nick,
> > > >
> > > > I am using the same thing in my real code, but for the sake of the
> > > isolation
> > > > test I have removed it.  The problem is not related to the actual
> upload
> > > > code or any of the com.oreilly package, since I'm not getting that
far
> > > > unless I work around the problem at hand by returning a
> > > different template
> > > > (than the one which made the request) to Velocity.  My test code
only
> > > > involves the single template and the single servlet.  To rule out
> Apache
> > > and
> > > > mod_jk, I may try to get it running with IIS (or with Tomcat's web
> > > server).
> > > >
> > > > I added the System.err.println(e.toString()), but it logs no
> exceptions.
> > > >
> > > > Shawn
> > > >
> > > > ----- Original Message -----
> > > > From: "Nick Temple" <nt...@alivecity.com>
> > > > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > > > Sent: Tuesday, July 02, 2002 1:11 PM
> > > > Subject: RE: Form upload failure
> > > >
> > > >
> > > > > Here is the system I am using to handle file-uploads:
> > > > >
> > > > > http://www.servlets.com/cos/index.html
> > > > >
> > > > > However, if the system doesn't hang when POSTing to a different
> > > > > form/servlet, I tend to think that it isn't the POST at all rather
> > > > > "something" in the code.
> > > > >
> > > > > Try writing some code in your try / except clause to see if
> > > an error is
> > > > > being thrown and ignored (and any places the servlet might be
> throwing
> > > an
> > > > > exception).
> > > > >
> > > > >   try
> > > > >   {
> > > > >    return getTemplate(templateName);
> > > > >   }
> > > > >   catch (Exception e)
> > > > >   {
> > > > >     System.err.println(e.toString());
> > > > >   }
> > > > >
> > > > > Nick
> > > > >
> > > > > -----Original Message-----
> > > > > From:
> > > velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> > > > >
> > >
[mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> > > > > rg]On Behalf Of Björn
> > > > > Sent: Tuesday, July 02, 2002 12:58 PM
> > > > > To: Velocity Users List
> > > > > Subject: Re: Form upload failure
> > > > >
> > > > >
> > > > > Do not know if this might be of any help to you...
> > > > >
> > > > > http://www.orionsupport.com/articles/fileupload.html
> > > > >
> > > > > It did help me once =)
> > > > >
> > > > >
> > > > > /Björn
> > > > > ----- Original Message -----
> > > > > From: "Shawn Church" <sh...@boxity.com>
> > > > > To: <ve...@jakarta.apache.org>
> > > > > Sent: Tuesday, July 02, 2002 7:17 PM
> > > > > Subject: Form upload failure
> > > > >
> > > > >
> > > > > Does anyone know of any limitations or problems with Velocity 1.2
/
> > > Apache
> > > > > 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
> > > containing
> > > > > <INPUT TYPE=FILE> ?  Specifically in the case where I have
> > > this type of
> > > > > template, whose form action is to invoke a servlet which then does
> > > nothing
> > > > > except return the same template (which made the request) to
> > > Velocity, I
> > > am
> > > > > getting this from Apache:
> > > > >
> > > > > HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
> > > Apache/1.3.24
> > > > > (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> > > > > Content-Type: text/html; charset=iso-8859-1
> > > > >
> > > > > This problem occurs if I select a file for upload, or if I do
> > > not select
> > > > > anything but rather just resubmit the form a few times in rapid
> > > > succession.
> > > > > If I do not select a file, and submit the form no more often than
> once
> > > per
> > > > > every couple of seconds, the problem does not occur.
> > > > >
> > > > > Here is a test template:
> > > > >
> > > > > <html>
> > > > > <form action="/ec/servlet/upload" method="post"
> > > > > enctype="multipart/form-data">
> > > > >   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> > > > > <input type=submit>
> > > > > </form>
> > > > > </html>
> > > > >
> > > > >
> > > > > Here's a snippet of the upload servlet, which is coded to do
nothing
> > > > except
> > > > > return the same form which made the request:
> > > > >
> > > > > ...
> > > > > public class upload extends VelocityServlet
> > > > > {
> > > > >  public Template handleRequest( HttpServletRequest _req,
> > > > HttpServletResponse
> > > > > _res, Context _context)
> > > > >  {
> > > > >   String templateName = "upload.vm";
> > > > >
> > > > >   // return the appropriate template
> > > > >   try
> > > > >   {
> > > > >    return getTemplate(templateName);
> > > > >     }
> > > > >     catch (Exception e)
> > > > >     {
> > > > >
> > > > >   }
> > > > >
> > > > >   return null;
> > > > >  }
> > > > > ...
> > > > >
> > > > > My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE
> 6.0,
> > > > > running on Win2k.  If my servlet returns a different template than
> the
> > > one
> > > > > which made the request, everything is fine.
> > > > >
> > > > > Shawn
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > > <ma...@jakarta.apache.org>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
FYI, I moved everything to IIS 5 and the problem went away.  However, I
really do not want to run this app on IIS because I plan on moving it to a
Linux box for production.  I can move to Tomcat 4 if no one can reproduce
the problem there.


Kevin,

The last code I sent was not a snippet.  Everything is stripped out for this
test, so there is only a single servlet and a single template.  There are no
globally-scoped objects in this code.

I should mention also that I have several other production servers running
both WebMacro (because Velocity didn't exist at the time they were
developed), and Velocity, which are perfectly stable under continuous usage,
so I am fairly confident this is unfortunately an issue with <input
type=file>.

Shawn

----- Original Message -----
From: "Kevin Baynes" <kb...@seagullsw.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 3:44 PM
Subject: RE: Form upload failure


>
> Shawn-
>
> I couldn't tell from the code snippet you sent whether my suspicion is
> correct.
>
> Look for any objects of global scope in the Servlet (ones that are outside
> of the scope of the methods), that are then modified or accessed within
the
> methods. This is an easy thing to let happen within a Servlet, but it
yields
> unpredictable behavior as an object is modified by one method while
another
> is still using it.
>
> I'd have to see the entire file to make sure, but it could be your
problem.
> You can also test this way: If all your action happens inside of
> handleRequest, you can add the "synchronized" keyword to the method
> declaration, that will prevent two threads from accessing the method at
the
> same time. Declare it synchronized and see if your problem goes away...
then
> fix it, don't leave it synchronized.
>
> ~kevin
>
>
>
> > -----Original Message-----
> > From: Shawn Church [mailto:shawn@boxity.com]
> > Sent: Tuesday, July 02, 2002 3:52 PM
> > To: Velocity Users List
> > Subject: Re: Form upload failure
> >
> >
> > Nick,
> >
> > I believe Velocity is getting called, because if I submit the
> > form multiple
> > times, but delay 2-3 seconds between submissions, I don't see a failure.
> > Also, once in a while the template gets rendered in the browser,
> > followed by
> > the (same) error message, so it seems Velocity is happy but
> > Apache / Tomcat
> > doesn't like the response.
> >
> > Thanks,
> > Shawn
> >
> > ----- Original Message -----
> > From: "Nick Temple" <nt...@alivecity.com>
> > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > Sent: Tuesday, July 02, 2002 2:26 PM
> > Subject: RE: Form upload failure
> >
> >
> > > Hi Shawn --
> > >
> > > I tend to agree with you.  I do know that uploaded files are a little
> > > messier to deal with, however since you aren't actually using the
> > paramaters
> > > I don't see how that could be a problem.
> > >
> > > I am curious to see where in the code it actually stops
> > processing.  Does
> > > Velocity even get called? Is the output thrown away by the
> > server engine?
> > > Anyway, I'm grasping at straws.
> > >
> > > Give me a couple of hours and I will get a version running on apache
> > 1.3.26
> > > / tomcat 4 and see if I can reproduce it.
> > >
> > > Nick
> > >
> > > -----Original Message-----
> > > From:
velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
> > >
[mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
> > > rg]On Behalf Of Shawn Church
> > > Sent: Tuesday, July 02, 2002 2:14 PM
> > > To: Velocity Users List
> > > Subject: Re: Form upload failure
> > >
> > >
> > > Nick,
> > >
> > > I am using the same thing in my real code, but for the sake of the
> > isolation
> > > test I have removed it.  The problem is not related to the actual
upload
> > > code or any of the com.oreilly package, since I'm not getting that far
> > > unless I work around the problem at hand by returning a
> > different template
> > > (than the one which made the request) to Velocity.  My test code only
> > > involves the single template and the single servlet.  To rule out
Apache
> > and
> > > mod_jk, I may try to get it running with IIS (or with Tomcat's web
> > server).
> > >
> > > I added the System.err.println(e.toString()), but it logs no
exceptions.
> > >
> > > Shawn
> > >
> > > ----- Original Message -----
> > > From: "Nick Temple" <nt...@alivecity.com>
> > > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > > Sent: Tuesday, July 02, 2002 1:11 PM
> > > Subject: RE: Form upload failure
> > >
> > >
> > > > Here is the system I am using to handle file-uploads:
> > > >
> > > > http://www.servlets.com/cos/index.html
> > > >
> > > > However, if the system doesn't hang when POSTing to a different
> > > > form/servlet, I tend to think that it isn't the POST at all rather
> > > > "something" in the code.
> > > >
> > > > Try writing some code in your try / except clause to see if
> > an error is
> > > > being thrown and ignored (and any places the servlet might be
throwing
> > an
> > > > exception).
> > > >
> > > >   try
> > > >   {
> > > >    return getTemplate(templateName);
> > > >   }
> > > >   catch (Exception e)
> > > >   {
> > > >     System.err.println(e.toString());
> > > >   }
> > > >
> > > > Nick
> > > >
> > > > -----Original Message-----
> > > > From:
> > velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> > > >
> > [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> > > > rg]On Behalf Of Björn
> > > > Sent: Tuesday, July 02, 2002 12:58 PM
> > > > To: Velocity Users List
> > > > Subject: Re: Form upload failure
> > > >
> > > >
> > > > Do not know if this might be of any help to you...
> > > >
> > > > http://www.orionsupport.com/articles/fileupload.html
> > > >
> > > > It did help me once =)
> > > >
> > > >
> > > > /Björn
> > > > ----- Original Message -----
> > > > From: "Shawn Church" <sh...@boxity.com>
> > > > To: <ve...@jakarta.apache.org>
> > > > Sent: Tuesday, July 02, 2002 7:17 PM
> > > > Subject: Form upload failure
> > > >
> > > >
> > > > Does anyone know of any limitations or problems with Velocity 1.2 /
> > Apache
> > > > 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
> > containing
> > > > <INPUT TYPE=FILE> ?  Specifically in the case where I have
> > this type of
> > > > template, whose form action is to invoke a servlet which then does
> > nothing
> > > > except return the same template (which made the request) to
> > Velocity, I
> > am
> > > > getting this from Apache:
> > > >
> > > > HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
> > Apache/1.3.24
> > > > (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> > > > Content-Type: text/html; charset=iso-8859-1
> > > >
> > > > This problem occurs if I select a file for upload, or if I do
> > not select
> > > > anything but rather just resubmit the form a few times in rapid
> > > succession.
> > > > If I do not select a file, and submit the form no more often than
once
> > per
> > > > every couple of seconds, the problem does not occur.
> > > >
> > > > Here is a test template:
> > > >
> > > > <html>
> > > > <form action="/ec/servlet/upload" method="post"
> > > > enctype="multipart/form-data">
> > > >   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> > > > <input type=submit>
> > > > </form>
> > > > </html>
> > > >
> > > >
> > > > Here's a snippet of the upload servlet, which is coded to do nothing
> > > except
> > > > return the same form which made the request:
> > > >
> > > > ...
> > > > public class upload extends VelocityServlet
> > > > {
> > > >  public Template handleRequest( HttpServletRequest _req,
> > > HttpServletResponse
> > > > _res, Context _context)
> > > >  {
> > > >   String templateName = "upload.vm";
> > > >
> > > >   // return the appropriate template
> > > >   try
> > > >   {
> > > >    return getTemplate(templateName);
> > > >     }
> > > >     catch (Exception e)
> > > >     {
> > > >
> > > >   }
> > > >
> > > >   return null;
> > > >  }
> > > > ...
> > > >
> > > > My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE
6.0,
> > > > running on Win2k.  If my servlet returns a different template than
the
> > one
> > > > which made the request, everything is fine.
> > > >
> > > > Shawn
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Form upload failure

Posted by Kevin Baynes <kb...@seagullsw.com>.
Shawn-

I couldn't tell from the code snippet you sent whether my suspicion is
correct.

Look for any objects of global scope in the Servlet (ones that are outside
of the scope of the methods), that are then modified or accessed within the
methods. This is an easy thing to let happen within a Servlet, but it yields
unpredictable behavior as an object is modified by one method while another
is still using it.

I'd have to see the entire file to make sure, but it could be your problem.
You can also test this way: If all your action happens inside of
handleRequest, you can add the "synchronized" keyword to the method
declaration, that will prevent two threads from accessing the method at the
same time. Declare it synchronized and see if your problem goes away... then
fix it, don't leave it synchronized.

~kevin



> -----Original Message-----
> From: Shawn Church [mailto:shawn@boxity.com]
> Sent: Tuesday, July 02, 2002 3:52 PM
> To: Velocity Users List
> Subject: Re: Form upload failure
>
>
> Nick,
>
> I believe Velocity is getting called, because if I submit the
> form multiple
> times, but delay 2-3 seconds between submissions, I don't see a failure.
> Also, once in a while the template gets rendered in the browser,
> followed by
> the (same) error message, so it seems Velocity is happy but
> Apache / Tomcat
> doesn't like the response.
>
> Thanks,
> Shawn
>
> ----- Original Message -----
> From: "Nick Temple" <nt...@alivecity.com>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 2:26 PM
> Subject: RE: Form upload failure
>
>
> > Hi Shawn --
> >
> > I tend to agree with you.  I do know that uploaded files are a little
> > messier to deal with, however since you aren't actually using the
> paramaters
> > I don't see how that could be a problem.
> >
> > I am curious to see where in the code it actually stops
> processing.  Does
> > Velocity even get called? Is the output thrown away by the
> server engine?
> > Anyway, I'm grasping at straws.
> >
> > Give me a couple of hours and I will get a version running on apache
> 1.3.26
> > / tomcat 4 and see if I can reproduce it.
> >
> > Nick
> >
> > -----Original Message-----
> > From: velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
> > [mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
> > rg]On Behalf Of Shawn Church
> > Sent: Tuesday, July 02, 2002 2:14 PM
> > To: Velocity Users List
> > Subject: Re: Form upload failure
> >
> >
> > Nick,
> >
> > I am using the same thing in my real code, but for the sake of the
> isolation
> > test I have removed it.  The problem is not related to the actual upload
> > code or any of the com.oreilly package, since I'm not getting that far
> > unless I work around the problem at hand by returning a
> different template
> > (than the one which made the request) to Velocity.  My test code only
> > involves the single template and the single servlet.  To rule out Apache
> and
> > mod_jk, I may try to get it running with IIS (or with Tomcat's web
> server).
> >
> > I added the System.err.println(e.toString()), but it logs no exceptions.
> >
> > Shawn
> >
> > ----- Original Message -----
> > From: "Nick Temple" <nt...@alivecity.com>
> > To: "Velocity Users List" <ve...@jakarta.apache.org>
> > Sent: Tuesday, July 02, 2002 1:11 PM
> > Subject: RE: Form upload failure
> >
> >
> > > Here is the system I am using to handle file-uploads:
> > >
> > > http://www.servlets.com/cos/index.html
> > >
> > > However, if the system doesn't hang when POSTing to a different
> > > form/servlet, I tend to think that it isn't the POST at all rather
> > > "something" in the code.
> > >
> > > Try writing some code in your try / except clause to see if
> an error is
> > > being thrown and ignored (and any places the servlet might be throwing
> an
> > > exception).
> > >
> > >   try
> > >   {
> > >    return getTemplate(templateName);
> > >   }
> > >   catch (Exception e)
> > >   {
> > >     System.err.println(e.toString());
> > >   }
> > >
> > > Nick
> > >
> > > -----Original Message-----
> > > From:
> velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> > >
> [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> > > rg]On Behalf Of Björn
> > > Sent: Tuesday, July 02, 2002 12:58 PM
> > > To: Velocity Users List
> > > Subject: Re: Form upload failure
> > >
> > >
> > > Do not know if this might be of any help to you...
> > >
> > > http://www.orionsupport.com/articles/fileupload.html
> > >
> > > It did help me once =)
> > >
> > >
> > > /Björn
> > > ----- Original Message -----
> > > From: "Shawn Church" <sh...@boxity.com>
> > > To: <ve...@jakarta.apache.org>
> > > Sent: Tuesday, July 02, 2002 7:17 PM
> > > Subject: Form upload failure
> > >
> > >
> > > Does anyone know of any limitations or problems with Velocity 1.2 /
> Apache
> > > 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
> containing
> > > <INPUT TYPE=FILE> ?  Specifically in the case where I have
> this type of
> > > template, whose form action is to invoke a servlet which then does
> nothing
> > > except return the same template (which made the request) to
> Velocity, I
> am
> > > getting this from Apache:
> > >
> > > HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
> Apache/1.3.24
> > > (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> > > Content-Type: text/html; charset=iso-8859-1
> > >
> > > This problem occurs if I select a file for upload, or if I do
> not select
> > > anything but rather just resubmit the form a few times in rapid
> > succession.
> > > If I do not select a file, and submit the form no more often than once
> per
> > > every couple of seconds, the problem does not occur.
> > >
> > > Here is a test template:
> > >
> > > <html>
> > > <form action="/ec/servlet/upload" method="post"
> > > enctype="multipart/form-data">
> > >   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> > > <input type=submit>
> > > </form>
> > > </html>
> > >
> > >
> > > Here's a snippet of the upload servlet, which is coded to do nothing
> > except
> > > return the same form which made the request:
> > >
> > > ...
> > > public class upload extends VelocityServlet
> > > {
> > >  public Template handleRequest( HttpServletRequest _req,
> > HttpServletResponse
> > > _res, Context _context)
> > >  {
> > >   String templateName = "upload.vm";
> > >
> > >   // return the appropriate template
> > >   try
> > >   {
> > >    return getTemplate(templateName);
> > >     }
> > >     catch (Exception e)
> > >     {
> > >
> > >   }
> > >
> > >   return null;
> > >  }
> > > ...
> > >
> > > My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> > > running on Win2k.  If my servlet returns a different template than the
> one
> > > which made the request, everything is fine.
> > >
> > > Shawn
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
Nick,

I believe Velocity is getting called, because if I submit the form multiple
times, but delay 2-3 seconds between submissions, I don't see a failure.
Also, once in a while the template gets rendered in the browser, followed by
the (same) error message, so it seems Velocity is happy but Apache / Tomcat
doesn't like the response.

Thanks,
Shawn

----- Original Message -----
From: "Nick Temple" <nt...@alivecity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 2:26 PM
Subject: RE: Form upload failure


> Hi Shawn --
>
> I tend to agree with you.  I do know that uploaded files are a little
> messier to deal with, however since you aren't actually using the
paramaters
> I don't see how that could be a problem.
>
> I am curious to see where in the code it actually stops processing.  Does
> Velocity even get called? Is the output thrown away by the server engine?
> Anyway, I'm grasping at straws.
>
> Give me a couple of hours and I will get a version running on apache
1.3.26
> / tomcat 4 and see if I can reproduce it.
>
> Nick
>
> -----Original Message-----
> From: velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
> [mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
> rg]On Behalf Of Shawn Church
> Sent: Tuesday, July 02, 2002 2:14 PM
> To: Velocity Users List
> Subject: Re: Form upload failure
>
>
> Nick,
>
> I am using the same thing in my real code, but for the sake of the
isolation
> test I have removed it.  The problem is not related to the actual upload
> code or any of the com.oreilly package, since I'm not getting that far
> unless I work around the problem at hand by returning a different template
> (than the one which made the request) to Velocity.  My test code only
> involves the single template and the single servlet.  To rule out Apache
and
> mod_jk, I may try to get it running with IIS (or with Tomcat's web
server).
>
> I added the System.err.println(e.toString()), but it logs no exceptions.
>
> Shawn
>
> ----- Original Message -----
> From: "Nick Temple" <nt...@alivecity.com>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 1:11 PM
> Subject: RE: Form upload failure
>
>
> > Here is the system I am using to handle file-uploads:
> >
> > http://www.servlets.com/cos/index.html
> >
> > However, if the system doesn't hang when POSTing to a different
> > form/servlet, I tend to think that it isn't the POST at all rather
> > "something" in the code.
> >
> > Try writing some code in your try / except clause to see if an error is
> > being thrown and ignored (and any places the servlet might be throwing
an
> > exception).
> >
> >   try
> >   {
> >    return getTemplate(templateName);
> >   }
> >   catch (Exception e)
> >   {
> >     System.err.println(e.toString());
> >   }
> >
> > Nick
> >
> > -----Original Message-----
> > From: velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> > [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> > rg]On Behalf Of Björn
> > Sent: Tuesday, July 02, 2002 12:58 PM
> > To: Velocity Users List
> > Subject: Re: Form upload failure
> >
> >
> > Do not know if this might be of any help to you...
> >
> > http://www.orionsupport.com/articles/fileupload.html
> >
> > It did help me once =)
> >
> >
> > /Björn
> > ----- Original Message -----
> > From: "Shawn Church" <sh...@boxity.com>
> > To: <ve...@jakarta.apache.org>
> > Sent: Tuesday, July 02, 2002 7:17 PM
> > Subject: Form upload failure
> >
> >
> > Does anyone know of any limitations or problems with Velocity 1.2 /
Apache
> > 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
containing
> > <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
> > template, whose form action is to invoke a servlet which then does
nothing
> > except return the same template (which made the request) to Velocity, I
am
> > getting this from Apache:
> >
> > HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
Apache/1.3.24
> > (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> > Content-Type: text/html; charset=iso-8859-1
> >
> > This problem occurs if I select a file for upload, or if I do not select
> > anything but rather just resubmit the form a few times in rapid
> succession.
> > If I do not select a file, and submit the form no more often than once
per
> > every couple of seconds, the problem does not occur.
> >
> > Here is a test template:
> >
> > <html>
> > <form action="/ec/servlet/upload" method="post"
> > enctype="multipart/form-data">
> >   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> > <input type=submit>
> > </form>
> > </html>
> >
> >
> > Here's a snippet of the upload servlet, which is coded to do nothing
> except
> > return the same form which made the request:
> >
> > ...
> > public class upload extends VelocityServlet
> > {
> >  public Template handleRequest( HttpServletRequest _req,
> HttpServletResponse
> > _res, Context _context)
> >  {
> >   String templateName = "upload.vm";
> >
> >   // return the appropriate template
> >   try
> >   {
> >    return getTemplate(templateName);
> >     }
> >     catch (Exception e)
> >     {
> >
> >   }
> >
> >   return null;
> >  }
> > ...
> >
> > My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> > running on Win2k.  If my servlet returns a different template than the
one
> > which made the request, everything is fine.
> >
> > Shawn
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: POSTing problem

Posted by Björn Andersson <sp...@student.bth.se>.
The web-hotel uses tomcat4 and I think I use velocity 1.2...

/Björn

----- Original Message -----
From: "Shawn Church" <sh...@boxity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 10:24 PM
Subject: Re: POSTing problem


> Björn,
>
> What server and version, as well as Velocity version, are you now using?
>
> Shawn
>
> ----- Original Message -----
> From: "Björn" <sp...@student.bth.se>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 2:44 PM
> Subject: POSTing problem
>
>
> > Hello!
> >
> > I have a little problem with my servlet. When sending froms with the
post
> method the server give the last sent "get-message" instead of the new
posted
> form. It is very confusing because the application did work fine when I
used
> the Orion-server. Then when I should go public didn't I find any
web-hotels
> using the Orion-server...
> >
> > /björn
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: POSTing problem

Posted by Shawn Church <sh...@boxity.com>.
Björn,

What server and version, as well as Velocity version, are you now using?

Shawn

----- Original Message -----
From: "Björn" <sp...@student.bth.se>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 2:44 PM
Subject: POSTing problem


> Hello!
>
> I have a little problem with my servlet. When sending froms with the post
method the server give the last sent "get-message" instead of the new posted
form. It is very confusing because the application did work fine when I used
the Orion-server. Then when I should go public didn't I find any web-hotels
using the Orion-server...
>
> /björn
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


POSTing problem

Posted by Björn <sp...@student.bth.se>.
Hello!

I have a little problem with my servlet. When sending froms with the post method the server give the last sent "get-message" instead of the new posted form. It is very confusing because the application did work fine when I used the Orion-server. Then when I should go public didn't I find any web-hotels using the Orion-server...

/björn


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Form upload failure

Posted by Nick Temple <nt...@alivecity.com>.
Hi Shawn --

I tend to agree with you.  I do know that uploaded files are a little
messier to deal with, however since you aren't actually using the paramaters
I don't see how that could be a problem.

I am curious to see where in the code it actually stops processing.  Does
Velocity even get called? Is the output thrown away by the server engine?
Anyway, I'm grasping at straws.

Give me a couple of hours and I will get a version running on apache 1.3.26
/ tomcat 4 and see if I can reproduce it.

Nick

-----Original Message-----
From: velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.org
[mailto:velocity-user-return-8057-ntemple=alivecity.com@jakarta.apache.o
rg]On Behalf Of Shawn Church
Sent: Tuesday, July 02, 2002 2:14 PM
To: Velocity Users List
Subject: Re: Form upload failure


Nick,

I am using the same thing in my real code, but for the sake of the isolation
test I have removed it.  The problem is not related to the actual upload
code or any of the com.oreilly package, since I'm not getting that far
unless I work around the problem at hand by returning a different template
(than the one which made the request) to Velocity.  My test code only
involves the single template and the single servlet.  To rule out Apache and
mod_jk, I may try to get it running with IIS (or with Tomcat's web server).

I added the System.err.println(e.toString()), but it logs no exceptions.

Shawn

----- Original Message -----
From: "Nick Temple" <nt...@alivecity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 1:11 PM
Subject: RE: Form upload failure


> Here is the system I am using to handle file-uploads:
>
> http://www.servlets.com/cos/index.html
>
> However, if the system doesn't hang when POSTing to a different
> form/servlet, I tend to think that it isn't the POST at all rather
> "something" in the code.
>
> Try writing some code in your try / except clause to see if an error is
> being thrown and ignored (and any places the servlet might be throwing an
> exception).
>
>   try
>   {
>    return getTemplate(templateName);
>   }
>   catch (Exception e)
>   {
>     System.err.println(e.toString());
>   }
>
> Nick
>
> -----Original Message-----
> From: velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> rg]On Behalf Of Björn
> Sent: Tuesday, July 02, 2002 12:58 PM
> To: Velocity Users List
> Subject: Re: Form upload failure
>
>
> Do not know if this might be of any help to you...
>
> http://www.orionsupport.com/articles/fileupload.html
>
> It did help me once =)
>
>
> /Björn
> ----- Original Message -----
> From: "Shawn Church" <sh...@boxity.com>
> To: <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 7:17 PM
> Subject: Form upload failure
>
>
> Does anyone know of any limitations or problems with Velocity 1.2 / Apache
> 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing
> <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
> template, whose form action is to invoke a servlet which then does nothing
> except return the same template (which made the request) to Velocity, I am
> getting this from Apache:
>
> HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24
> (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> Content-Type: text/html; charset=iso-8859-1
>
> This problem occurs if I select a file for upload, or if I do not select
> anything but rather just resubmit the form a few times in rapid
succession.
> If I do not select a file, and submit the form no more often than once per
> every couple of seconds, the problem does not occur.
>
> Here is a test template:
>
> <html>
> <form action="/ec/servlet/upload" method="post"
> enctype="multipart/form-data">
>   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> <input type=submit>
> </form>
> </html>
>
>
> Here's a snippet of the upload servlet, which is coded to do nothing
except
> return the same form which made the request:
>
> ...
> public class upload extends VelocityServlet
> {
>  public Template handleRequest( HttpServletRequest _req,
HttpServletResponse
> _res, Context _context)
>  {
>   String templateName = "upload.vm";
>
>   // return the appropriate template
>   try
>   {
>    return getTemplate(templateName);
>     }
>     catch (Exception e)
>     {
>
>   }
>
>   return null;
>  }
> ...
>
> My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> running on Win2k.  If my servlet returns a different template than the one
> which made the request, everything is fine.
>
> Shawn
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
Nick,

I am using the same thing in my real code, but for the sake of the isolation
test I have removed it.  The problem is not related to the actual upload
code or any of the com.oreilly package, since I'm not getting that far
unless I work around the problem at hand by returning a different template
(than the one which made the request) to Velocity.  My test code only
involves the single template and the single servlet.  To rule out Apache and
mod_jk, I may try to get it running with IIS (or with Tomcat's web server).

I added the System.err.println(e.toString()), but it logs no exceptions.

Shawn

----- Original Message -----
From: "Nick Temple" <nt...@alivecity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 1:11 PM
Subject: RE: Form upload failure


> Here is the system I am using to handle file-uploads:
>
> http://www.servlets.com/cos/index.html
>
> However, if the system doesn't hang when POSTing to a different
> form/servlet, I tend to think that it isn't the POST at all rather
> "something" in the code.
>
> Try writing some code in your try / except clause to see if an error is
> being thrown and ignored (and any places the servlet might be throwing an
> exception).
>
>   try
>   {
>    return getTemplate(templateName);
>   }
>   catch (Exception e)
>   {
>     System.err.println(e.toString());
>   }
>
> Nick
>
> -----Original Message-----
> From: velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
> [mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
> rg]On Behalf Of Björn
> Sent: Tuesday, July 02, 2002 12:58 PM
> To: Velocity Users List
> Subject: Re: Form upload failure
>
>
> Do not know if this might be of any help to you...
>
> http://www.orionsupport.com/articles/fileupload.html
>
> It did help me once =)
>
>
> /Björn
> ----- Original Message -----
> From: "Shawn Church" <sh...@boxity.com>
> To: <ve...@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 7:17 PM
> Subject: Form upload failure
>
>
> Does anyone know of any limitations or problems with Velocity 1.2 / Apache
> 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing
> <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
> template, whose form action is to invoke a servlet which then does nothing
> except return the same template (which made the request) to Velocity, I am
> getting this from Apache:
>
> HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24
> (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> Content-Type: text/html; charset=iso-8859-1
>
> This problem occurs if I select a file for upload, or if I do not select
> anything but rather just resubmit the form a few times in rapid
succession.
> If I do not select a file, and submit the form no more often than once per
> every couple of seconds, the problem does not occur.
>
> Here is a test template:
>
> <html>
> <form action="/ec/servlet/upload" method="post"
> enctype="multipart/form-data">
>   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> <input type=submit>
> </form>
> </html>
>
>
> Here's a snippet of the upload servlet, which is coded to do nothing
except
> return the same form which made the request:
>
> ...
> public class upload extends VelocityServlet
> {
>  public Template handleRequest( HttpServletRequest _req,
HttpServletResponse
> _res, Context _context)
>  {
>   String templateName = "upload.vm";
>
>   // return the appropriate template
>   try
>   {
>    return getTemplate(templateName);
>     }
>     catch (Exception e)
>     {
>
>   }
>
>   return null;
>  }
> ...
>
> My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> running on Win2k.  If my servlet returns a different template than the one
> which made the request, everything is fine.
>
> Shawn
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Form upload failure

Posted by Nick Temple <nt...@alivecity.com>.
Here is the system I am using to handle file-uploads:

http://www.servlets.com/cos/index.html

However, if the system doesn't hang when POSTing to a different
form/servlet, I tend to think that it isn't the POST at all rather
"something" in the code.

Try writing some code in your try / except clause to see if an error is
being thrown and ignored (and any places the servlet might be throwing an
exception).

  try
  {
   return getTemplate(templateName);
  }
  catch (Exception e)
  {
    System.err.println(e.toString());
  }

Nick

-----Original Message-----
From: velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.org
[mailto:velocity-user-return-8053-ntemple=alivecity.com@jakarta.apache.o
rg]On Behalf Of Björn
Sent: Tuesday, July 02, 2002 12:58 PM
To: Velocity Users List
Subject: Re: Form upload failure


Do not know if this might be of any help to you...

http://www.orionsupport.com/articles/fileupload.html

It did help me once =)


/Björn
----- Original Message -----
From: "Shawn Church" <sh...@boxity.com>
To: <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 7:17 PM
Subject: Form upload failure


Does anyone know of any limitations or problems with Velocity 1.2 / Apache
1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing
<INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
template, whose form action is to invoke a servlet which then does nothing
except return the same template (which made the request) to Velocity, I am
getting this from Apache:

HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24
(Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

This problem occurs if I select a file for upload, or if I do not select
anything but rather just resubmit the form a few times in rapid succession.
If I do not select a file, and submit the form no more often than once per
every couple of seconds, the problem does not occur.

Here is a test template:

<html>
<form action="/ec/servlet/upload" method="post"
enctype="multipart/form-data">
  Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
<input type=submit>
</form>
</html>


Here's a snippet of the upload servlet, which is coded to do nothing except
return the same form which made the request:

...
public class upload extends VelocityServlet
{
 public Template handleRequest( HttpServletRequest _req, HttpServletResponse
_res, Context _context)
 {
  String templateName = "upload.vm";

  // return the appropriate template
  try
  {
   return getTemplate(templateName);
    }
    catch (Exception e)
    {

  }

  return null;
 }
...

My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
running on Win2k.  If my servlet returns a different template than the one
which made the request, everything is fine.

Shawn




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Björn <sp...@student.bth.se>.
Do not know if this might be of any help to you...

http://www.orionsupport.com/articles/fileupload.html

It did help me once =)


/Björn
----- Original Message ----- 
From: "Shawn Church" <sh...@boxity.com>
To: <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 7:17 PM
Subject: Form upload failure


Does anyone know of any limitations or problems with Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of template, whose form action is to invoke a servlet which then does nothing except return the same template (which made the request) to Velocity, I am getting this from Apache:

HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24 (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 

This problem occurs if I select a file for upload, or if I do not select anything but rather just resubmit the form a few times in rapid succession.  If I do not select a file, and submit the form no more often than once per every couple of seconds, the problem does not occur.

Here is a test template:

<html>
<form action="/ec/servlet/upload" method="post" enctype="multipart/form-data">
  Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
<input type=submit>
</form>
</html>


Here's a snippet of the upload servlet, which is coded to do nothing except return the same form which made the request:

...
public class upload extends VelocityServlet
{
 public Template handleRequest( HttpServletRequest _req, HttpServletResponse _res, Context _context)
 {
  String templateName = "upload.vm";
 
  // return the appropriate template
  try 
  {
   return getTemplate(templateName);
    } 
    catch (Exception e) 
    {
   
  }

  return null;
 }
... 

My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0, running on Win2k.  If my servlet returns a different template than the one which made the request, everything is fine.

Shawn




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
Kevin,

> That "HTTP/1.1 200 OK" status code means that the request has succeeded.

True.

>
> Can you clarify "If my servlet returns a different template than the
> > one which made the request, everything is fine." for me?
>

My servlet (upload) always returns getTemplate("upload.vm"), and the
template's <form action is always the upload class.  This would be a normal
situation where, for example, you need to validate form input prior to
processing, and in the case of an invalid input the servlet will request the
same template to be presented again.

> It seems that you are uploading a file (which is working, file on server
> now?) and then merging a template called "upload.vm" to return back to the
> browser? I assume this template just contains the <form> that allows
upload
> of another file? Are you saying that if you use any other template in
> getTemplate(name) that it returns to the browser?

The code I'm testing with is not concerned with the actual file upload, but
rather is just attempting to isolate a problem which occurs prior to the
upload code being invoked.  In my real code, the actual upload works fine,
but only if I don't return the same (requesting) template back to Velocity.
I've stripped everything non-essential, so I only have a single servlet and
a single template.

It would be interesting to know if you experience the same problem by
implementing nothing more than this single template and the servlet below.
When you see the default "Browse" button on your browser page, select a file
to upload, then click Submit.  This is where the exception occurs (the fact
that no code exists to actually process the file upload request is not
relevant to reproduce the problem).

I provided the complete template earlier, and here's the complete servlet
(per Nick's request, I added the System.err.println(e.toString()); to the
catch code, but it doesn't produce any exceptions):

...
package com.gc.ecr;

import java.io.*;
import java.net.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.velocity.Template;
import org.apache.velocity.context.Context;
import org.apache.velocity.servlet.VelocityServlet;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.ParseErrorException;

public class upload extends VelocityServlet
{
 public Template handleRequest( HttpServletRequest _req, HttpServletResponse
_res, Context _context)
 {
  String templateName = "upload.vm";

  // return the appropriate template
  try
  {
   return getTemplate(templateName);
    }
    catch (Exception e)
    {
    System.err.println(e.toString());
  }

  return null;
 }


 /**
 *  A fancier version of loadConfiguration(), this will
 *  set the log file to be off of the webapp root, and
 *  will do the same with the file loader paths
 */
 protected Properties loadConfiguration(ServletConfig config )
   throws IOException, FileNotFoundException
 {
  /*
    *  get our properties file and load it
    */

  String propsFile = config.getInitParameter(INIT_PROPS_KEY);
  Properties p = new Properties();

  if ( propsFile != null )
  {
     String realPath = getServletContext().getRealPath(propsFile);

     if ( realPath != null )
     {
         propsFile = realPath;
     }

     p.load( new FileInputStream(propsFile) );
  }

  /*
  *  first, normalize our velocity log file to be in the
  *  webapp
  */

  String log = p.getProperty( Velocity.RUNTIME_LOG);

  if (log != null )
  {
     log = getServletContext().getRealPath( log );

     if (log != null)
     {
         p.setProperty( Velocity.RUNTIME_LOG, log );
     }
  }

  /*
  *  now, if there is a file loader resource path, treat it the
  *  same way.
  */

  String path = p.getProperty( Velocity.FILE_RESOURCE_LOADER_PATH );

  if ( path != null)
  {
     path = getServletContext().getRealPath(  path );

     if ( path != null)
     {
         p.setProperty( Velocity.FILE_RESOURCE_LOADER_PATH, path );
     }
  }

  return p;
 }
}



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Form upload failure

Posted by Kevin Baynes <kb...@seagullsw.com>.
Shawn-

That "HTTP/1.1 200 OK" status code means that the request has succeeded.

Can you clarify "If my servlet returns a different template than the
> one which made the request, everything is fine." for me?

It seems that you are uploading a file (which is working, file on server
now?) and then merging a template called "upload.vm" to return back to the
browser? I assume this template just contains the <form> that allows upload
of another file? Are you saying that if you use any other template in
getTemplate(name) that it returns to the browser?

Also, can you include the entire Servlet code for upload.java, I have a
couple of suspicions that I could rule out if I could see the whole thing.


-------------------------------
Kevin Baynes

"Nothing left to do but Smile, Smile, Smile!"



> -----Original Message-----
> From: Shawn Church [mailto:shawn@boxity.com]
> Sent: Tuesday, July 02, 2002 1:17 PM
> To: velocity-user@jakarta.apache.org
> Subject: Form upload failure
>
>
> Does anyone know of any limitations or problems with Velocity 1.2 /
> Apache 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates
> containing <INPUT TYPE=FILE> ?  Specifically in the case where I have
> this type of template, whose form action is to invoke a servlet which
> then does nothing except return the same template (which made the
> request) to Velocity, I am getting this from Apache:
>
> HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server:
> Apache/1.3.24 (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding:
> chunked Content-Type: text/html; charset=iso-8859-1
>
> This problem occurs if I select a file for upload, or if I do not select
> anything but rather just resubmit the form a few times in rapid
> succession.  If I do not select a file, and submit the form no more
> often than once per every couple of seconds, the problem does not occur.
>
> Here is a test template:
>
> <html>
> <form action="/ec/servlet/upload" method="post"
> enctype="multipart/form-data">
>   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> <input type=submit>
> </form>
> </html>
>
>
> Here's a snippet of the upload servlet, which is coded to do nothing
> except return the same form which made the request:
>
> ...
> public class upload extends VelocityServlet
> {
>  public Template handleRequest( HttpServletRequest _req,
> HttpServletResponse _res, Context _context)
>  {
>   String templateName = "upload.vm";
>
>   // return the appropriate template
>   try
>   {
>    return getTemplate(templateName);
>     }
>     catch (Exception e)
>     {
>
>   }
>
>   return null;
>  }
> ...
>
> My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> running on Win2k.  If my servlet returns a different template than the
> one which made the request, everything is fine.
>
> Shawn
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Form upload failure

Posted by Shawn Church <sh...@boxity.com>.
Nick,

Thanks for the suggestion, but it didn't seem to affect this particular
problem.  I'm getting this:

HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 17:36:45 GMT Server: Apache/1.3.26
(Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

I also intended to mention I'm using jdk1.4, and I am not seeing any
exceptions in the velocity.log file.  I haven't yet dug into the velocity
source, but I think it's interesting that returning a different template
seems to not produce the exception.

Shawn


----- Original Message -----
From: "Nick Temple" <nt...@alivecity.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 02, 2002 12:26 PM
Subject: RE: Form upload failure


> Hi Shawn --
>
> I am aware of a bug in Apache 1.3.24 (and below) having to do with chunked
> encodings, however the detals are unclear to me other than it is a
"security
> risk".  Regardless, the first thing I'd try is upgrading to Apache 1.3.26.
>
> Here's the info: http://httpd.apache.org (scroll down a little to SECURITY
> ADVISORY).
>
> Nick
>
> -----Original Message-----
> From: velocity-user-return-8050-ntemple=alivecity.com@jakarta.apache.org
> [mailto:velocity-user-return-8050-ntemple=alivecity.com@jakarta.apache.o
> rg]On Behalf Of Shawn Church
> Sent: Tuesday, July 02, 2002 12:17 PM
> To: velocity-user@jakarta.apache.org
> Subject: Form upload failure
>
>
> Does anyone know of any limitations or problems with Velocity 1.2 / Apache
> 1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing
> <INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
> template, whose form action is to invoke a servlet which then does nothing
> except return the same template (which made the request) to Velocity, I am
> getting this from Apache:
>
> HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24
> (Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
> Content-Type: text/html; charset=iso-8859-1
>
> This problem occurs if I select a file for upload, or if I do not select
> anything but rather just resubmit the form a few times in rapid
succession.
> If I do not select a file, and submit the form no more often than once per
> every couple of seconds, the problem does not occur.
>
> Here is a test template:
>
> <html>
> <form action="/ec/servlet/upload" method="post"
> enctype="multipart/form-data">
>   Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
> <input type=submit>
> </form>
> </html>
>
>
> Here's a snippet of the upload servlet, which is coded to do nothing
except
> return the same form which made the request:
>
> ...
> public class upload extends VelocityServlet
> {
>  public Template handleRequest( HttpServletRequest _req,
HttpServletResponse
> _res, Context _context)
>  {
>   String templateName = "upload.vm";
>
>   // return the appropriate template
>   try
>   {
>    return getTemplate(templateName);
>     }
>     catch (Exception e)
>     {
>
>   }
>
>   return null;
>  }
> ...
>
> My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
> running on Win2k.  If my servlet returns a different template than the one
> which made the request, everything is fine.
>
> Shawn
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Form upload failure

Posted by Nick Temple <nt...@alivecity.com>.
Hi Shawn --

I am aware of a bug in Apache 1.3.24 (and below) having to do with chunked
encodings, however the detals are unclear to me other than it is a "security
risk".  Regardless, the first thing I'd try is upgrading to Apache 1.3.26.

Here's the info: http://httpd.apache.org (scroll down a little to SECURITY
ADVISORY).

Nick

-----Original Message-----
From: velocity-user-return-8050-ntemple=alivecity.com@jakarta.apache.org
[mailto:velocity-user-return-8050-ntemple=alivecity.com@jakarta.apache.o
rg]On Behalf Of Shawn Church
Sent: Tuesday, July 02, 2002 12:17 PM
To: velocity-user@jakarta.apache.org
Subject: Form upload failure


Does anyone know of any limitations or problems with Velocity 1.2 / Apache
1.3.24 / Tomcat 3.3a, relating to multipart/form-data templates containing
<INPUT TYPE=FILE> ?  Specifically in the case where I have this type of
template, whose form action is to invoke a servlet which then does nothing
except return the same template (which made the request) to Velocity, I am
getting this from Apache:

HTTP/1.1 200 OK Date: Tue, 02 Jul 2002 16:48:35 GMT Server: Apache/1.3.24
(Win32) mod_jk/1.1.0 Connection: close Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1

This problem occurs if I select a file for upload, or if I do not select
anything but rather just resubmit the form a few times in rapid succession.
If I do not select a file, and submit the form no more often than once per
every couple of seconds, the problem does not occur.

Here is a test template:

<html>
<form action="/ec/servlet/upload" method="post"
enctype="multipart/form-data">
  Which file to upload? <INPUT TYPE=FILE NAME=file1> <BR>
<input type=submit>
</form>
</html>


Here's a snippet of the upload servlet, which is coded to do nothing except
return the same form which made the request:

...
public class upload extends VelocityServlet
{
 public Template handleRequest( HttpServletRequest _req, HttpServletResponse
_res, Context _context)
 {
  String templateName = "upload.vm";

  // return the appropriate template
  try
  {
   return getTemplate(templateName);
    }
    catch (Exception e)
    {

  }

  return null;
 }
...

My environment is Velocity 1.2 / Apache 1.3.24 / Tomcat 3.3a, IE 6.0,
running on Win2k.  If my servlet returns a different template than the one
which made the request, everything is fine.

Shawn



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>