RE: multipart requests and file uploads problems on the Apache connection

2001-04-12 Thread Sandy McPherson

You need tp use Ajp12 for multipart request servlets.
Just specify something like this
#
# The following line mounts all JSP files and the /spqr/servlet/ uri to
tomcat
#
JkMount /spqr/servlet/* ajp13
JkMount /spqr/servlet/LogoUpload ajp12 # Ajp13 won't handle the multi-part
request properly
JkMount /spqr/*.jsp ajp13

I believe there is a patch somewhere in the CVS repository, but seeing as we
Upload Files once in a blue-moon, and the "slower" Ajp12 does the job, I
haven't bothered. Never fix a running system!

Sandy

> -Original Message-
> From: Bard [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, April 08, 2001 4:19 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: multipart requests and file uploads problems on the Apache
> connection
>
>
> Hello Sandy McPherson,
>
>
> Sorry to be mailing you directly, but I've had exactly the problems you
> described in you posting
>
> (http://archive.covalent.net/jakarta/tomcat-user/2000/12/0612.xml)
>
> and have been trying to find an answer for weeks now. Have you found out
> how Apache+mod_jk+tomcat can be configured properly to allow binary file
> uploads using servlets or JSPs? I tried the code that uses
> PerTools as well
> as several other variations with exactly the same "infinite loop" of
> "Y"s appearing in the console where tomcat was started.
>
> Very frustrated,
>
> Bard
>
>




RE: multipart requests and file uploads problems on the Apache connection

2000-12-08 Thread CPC Livelink Admin

That's interesting, since I've been doing that for some time now with no
issues.

-Original Message-
From: Jose Euclides da Silva Junior - DIGR.O
[mailto:[EMAIL PROTECTED]]
Sent: Friday, December 08, 2000 03:20 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RES: multipart requests and file uploads problems on the Apache
connection


-BEGIN PGP SIGNED MESSAGE-

Hi, everybody! Unfortunately, it seems that there is an important limitation
when  using Jason's components. The developer cant mix text fields and file
setting fields in the form!
Good luck,

José Euclides Júnior
__
E-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://euclides.8m.com


- -Mensagem original-
De: Joe Laffey [SMTP:[EMAIL PROTECTED]]
Enviada em: Quinta-feira, 7 de Dezembro de 2000 13:50
Para:   [EMAIL PROTECTED]; [EMAIL PROTECTED]
Assunto:        Re: multipart requests and file uploads problems on
the Apache connection

Take a look at the multipart classes by Jason Hunter that are free for use
if you own the book "Java Servlet Programming" from O'Reilly. The code can
be downloaded from O'Reilly's site www.ora.com

I have only had one problem with it, and I think I have coded around it.
The problem was that sometimes uploads from MSIE 5.01 Win do not send the
boundary correctly (it varies by two characters everytime).


Joe Laffey
LAFFEY Computer Imaging
St. Louis, MO
- -
With no walls or fences on the Internet, who needs Windows or Gates?
- -
-BEGIN PGP SIGNATURE-
Version: PGP 6.5.1

iQCVAwUBOjFcat0YhuJ3BUxtAQEO+QP+LW4a8HpIGlHQr1Mpj0IGbkuwwVBXGpR4
0g4iWIGJXn5hmAFkyC35jZTokqqw8AM1+u77jLlKPt9lHeohrSyXLPwWCmWrSiKR
bDGHJ9Z/i3eZw4QF+se7dvjfGR1IdJLRgqDmVAwIF40GPICtcpMxefGzN3KfjLzx
U9DdkA2DJMU=
=ddTy
-END PGP SIGNATURE-




RE: multipart requests and file uploads problems on the Apache connection

2000-12-07 Thread David Rees

Yes, this is a known bug in Ajp13.  It looks like a fix is under development
and should be available in the next release.  Until then, use Ajp12.

-Dave

> Sandy McPherson wrote:
>
> Looks like the Ajp13 is screwing up! The stuff works properly
> when I set the servlet protocol to Ajp12
>
> > Hi
> >
> > I am running Tomcat 3.2 and Apache 1.3.12.
> >
> > I get some funny behaviour when uploading a file through the
> > apache/tomcat connection. It looks like the input stream is broken.
> >
> > The output from Tomcat looks like
> >
> > Using classpath:
> >
> /usr/local/tomcat/lib/ant.jar:/usr/local/tomcat/lib/jasper.jar:/us
> r/local/tomcat/lib/servlet.jar:/usr/local/tomcat/lib/test:/usr/loc
> al/tomcat/lib/webserver.jar:/usr/java/jdk/lib/tools.jar:/usr/java/
> jsse/lib/jcert.jar:/usr/java/jsse/lib/jsse.jar:/usr/java/jsse/lib/
> jnet.jar:/usr/java/jaxp/jaxp.jar:/usr/java/jaxp/parser.jar:/usr/ja
> va/jdk/bin
> >
> > Starting tomcat. Check logs/tomcat.log for error messages
> >
> > >> upload GIF using http://localhost:8080/spqr/servlet/LogoUpload
> >
> > LogoUpload.service: begin
> > LogoUpload.service: reading file
> > LogoUpload.service: reading new block len = 5283,5283
> > LogoUpload.service: reading file completed
> > LogoUpload.service: file is GIF
> > LogoUpload.service: looking for footer
> > LogoUpload.service: found footer
> > LogoUpload.service: end
> >




Re: multipart requests and file uploads problems on the Apache connection

2000-12-07 Thread Sandy McPherson

Sandy McPherson wrote:

Looks like the Ajp13 is screwing up! The stuff works properly when I set the servlet 
protocol to Ajp12


> Hi
>
> I am running Tomcat 3.2 and Apache 1.3.12.
>
> I get some funny behaviour when uploading a file through the
> apache/tomcat connection. It looks like the input stream is broken.
>
> The output from Tomcat looks like
>
> Using classpath:
> 
>/usr/local/tomcat/lib/ant.jar:/usr/local/tomcat/lib/jasper.jar:/usr/local/tomcat/lib/servlet.jar:/usr/local/tomcat/lib/test:/usr/local/tomcat/lib/webserver.jar:/usr/java/jdk/lib/tools.jar:/usr/java/jsse/lib/jcert.jar:/usr/java/jsse/lib/jsse.jar:/usr/java/jsse/lib/jnet.jar:/usr/java/jaxp/jaxp.jar:/usr/java/jaxp/parser.jar:/usr/java/jdk/bin
>
> Starting tomcat. Check logs/tomcat.log for error messages
>
> >> upload GIF using http://localhost:8080/spqr/servlet/LogoUpload
>
> LogoUpload.service: begin
> LogoUpload.service: reading file
> LogoUpload.service: reading new block len = 5283,5283
> LogoUpload.service: reading file completed
> LogoUpload.service: file is GIF
> LogoUpload.service: looking for footer
> LogoUpload.service: found footer
> LogoUpload.service: end
>
> >> upload GIF using http://localhost/spqr/servlet/LogoUpload i.e.
> over
>
> LogoUpload.service: begin
> LogoUpload.service: reading file
> Y
> LogoUpload.service: reading new block len = 340,340
> Y
> LogoUpload.service: reading new block len = 0,340
> Y
> LogoUpload.service: reading new block len = 0,340
> Y
> ...
> LogoUpload.service: reading new block len = 0,340
> Y
>
> in an infinite loop!
>
> My code  (attached) does not print the Y anywhere that I can see!
>
> The Apache httpd.conf file is out of the box with the mod_jk.conf.spqr
> (attached) file included right at
> the end.
>
> Do I have to configure anything in Apache to get it to pass the
> multi-part request without mangling it?
> Thanks
> Sandy
>
>   
> package com.mapquest.spqr.db;
>
> import java.io.*;
> import java.net.*;
> import java.util.*;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> import com.oroinc.text.perl.*;
>
> public class LogoUpload extends HttpServlet
> {
>public static final int maxFileSize=65535;
>String[] getFileTypes( )
>{
>   return new String[] {".gif",".jpg", ".jpeg" };
>}
>public void service( HttpServletRequest _req, HttpServletResponse _res )
>   throws ServletException, IOException
>{
>   System.out.println( "LogoUpload.service: begin" );
>   Client client = (Client)_req.getSession( ).getAttribute( "client" );
>   if ( client == null )
>   {
>  throw new ServletException( "No bean called \"client\" in session" 
>);
>   }
>   String user=client.getUser( );
>   //
>   // Input and Output streams
>   //
>   InputStream is = _req.getInputStream();
>   //
>   // Temporary ByteArray.The initial size is set to 8164.
>   // A large initial size improves performance.
>   //
>   ByteArrayOutputStream bos = new ByteArrayOutputStream(8164);
>
>   //
>   // The files total length,including header and footer
>   //
>   int TotLen=0;
>   int HeaderLen=0;
>   int FooterLen=0;
>
>   //
>   // byte array for read
>   //
>   byte[] b = new byte[8164];
>   int len=0;
>
>   //
>   // Read the InputStream and store it in 'bos'.
>   //
>   System.out.println( "LogoUpload.service: reading file" );
>   try
>   {
>  while( ((len = is.read(b,0,8164)) != -1) && TotLen <= maxFileSize )
>  {
> bos.write(b,0,len);
>
> TotLen += len;
> System.out.println( "LogoUpload.service: reading new block 
>len = "+len + "," +TotLen );
>  }
>  is.close();
>  System.out.println( "LogoUpload.service: reading file completed" );
>   }
>   catch(IOException e)
>   {
>  System.out.println( "LogoUpload.service: upload failed" );
>  throw new ServletException( "File upload failed", e );
>   }
>
>   if ( TotLen > maxFileSize )
>   {
>  System.out.println( "LogoUpload.service: file too big" );
>  getServletContext( )
> .getRequestDispatcher("/"+client.getDefaultLanguage( 
>)+"/logo-big.jsp")
> .forward( _req, _res );
>  return;
>   }
>
>   String fileExtension = null;
>   try
>   {
>  String GIFRegex = "/Content-Type: image/gif\r\n\r\n/";
>  String PJPEGRegex = "/Content-Type: image/pjpeg\r\n\r\n/";
>  String JPEGRegex = "/Conte