You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Hristo Kosev <hk...@yahoo.com> on 2001/08/07 16:29:41 UTC

Problems with UploadService

Hi,
I have problems with UploadService.
When I try to upload a ".gif" or ".txt" file FileItem
writes 0 bytes long file. When I upload ".doc" or
".jpg" file the file uploads successfully(I haven't
experimented with other file types).
My Turbine Version is 2.1(the one that comes with TDK
2.1)

Here's the code that I use to upload the file:
FileItem fileItem =
data.getParameters().getFileItem("file");
fileItem.write(TurbineServlet.getRealPath("uploaded.file"));

The form in the template file is with "enctype" set to
"multipart/form-data".

Thanks in advance for any help I get!
Hristo Kosev

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Problems with UploadService

Posted by Daniel Rall <dl...@finemaltcoding.com>.
"Paal Hagerup" <pa...@dph.no> writes:

> 2.1 have a bug in FileItem.write().
> 
> Here is a workaround:
> 
> FileItem file = pp.getFileItem( "fileName" );
> if (file.inMemory())
> {
>    FileWriter writer = new FileWriter( destination );
>    writer.write( file.getString() );
>    writer.close(); // Missing in FileItem.writer()
> }
> else
> {
>    file.write( destination );
> }
> 
> If I only knew how to make a patch I would submit one...

I've added this fix to the HEAD of jakarta-turbine-2.  Thanks Paal.

Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Problems with UploadService

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/23/01 7:41 AM, "Paal Hagerup" <pa...@dph.no> wrote:

> If I only knew how to make a patch I would submit one...
> 
> Paal Hagerup

<http://jakarta.apache.org/site/source.html>

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Problems with UploadService

Posted by Jon Stevens <jo...@latchkey.com>.
on 8/23/01 7:41 AM, "Paal Hagerup" <pa...@dph.no> wrote:

> 2.1 have a bug in FileItem.write().
> 
> Here is a workaround:
> 
> FileItem file = pp.getFileItem( "fileName" );
> if (file.inMemory())
> {
>  FileWriter writer = new FileWriter( destination );
>  writer.write( file.getString() );
>  writer.close(); // Missing in FileItem.writer()
> }
> else
> {
>  file.write( destination );
> }
> 
> If I only knew how to make a patch I would submit one...
> 
> Paal Hagerup

This has now been fixed in the DefaultFileItem.java in
jakarta-turbine-fulcrum

Thanks.

FYI, you should wrap the above in a try/finally so that you can be assured
it is closed if the write fails for some reason.

-jon


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Problems with UploadService

Posted by Paal Hagerup <pa...@dph.no>.
2.1 have a bug in FileItem.write().

Here is a workaround:

FileItem file = pp.getFileItem( "fileName" );
if (file.inMemory())
{
   FileWriter writer = new FileWriter( destination );
   writer.write( file.getString() );
   writer.close(); // Missing in FileItem.writer()
}
else
{
   file.write( destination );
}

If I only knew how to make a patch I would submit one...

Paal Hagerup


Gunter Miessbrandt wrote:
> Hi,
> I have problems with UploadService.
> When I try to upload a file FileItem
> often writes 0 bytes long file. The upload work fine as long as the file is
> a jpg-graphic. With other extensions it doesn?t work. Sometimes the
> jpg-files are only half loaded.
> My Turbine Version is 2.1.
> 
> Here's the code that I use to upload the file:
> FileItem fileItem =
> data.getParameters().getFileItem("file");
> fileItem.write(TurbineServlet.getRealPath("uploaded.file"));
> 
> The form in the template file is with "enctype" set to
> "multipart/form-data".
> I have searched the archives but found no answer.
> 
> Thanks in advance for any help I get!
> Gunter Miessbrandt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


AW: Problems with UploadService

Posted by Gunter Miessbrandt <mi...@ixtern.de>.
Thanks that works!!!
And the solution was so easy ;-)
Gunter Miessbrandt

-----Ursprungliche Nachricht-----
Von: Jason van Zyl [mailto:jvanzyl@apache.org]
Gesendet: Donnerstag, 23. August 2001 16:33
An: turbine-user@jakarta.apache.org
Betreff: Re: Problems with UploadService


On 8/23/01 10:28 AM, "Gunter Miessbrandt" <mi...@ixtern.de> wrote:

> Hi,
> I have problems with UploadService.
> When I try to upload a file FileItem
> often writes 0 bytes long file. The upload work fine as long as the file
is
> a jpg-graphic. With other extensions it doesn?t work. Sometimes the
> jpg-files are only half loaded.
> My Turbine Version is 2.1.
>
> Here's the code that I use to upload the file:
> FileItem fileItem =
> data.getParameters().getFileItem("file");
> fileItem.write(TurbineServlet.getRealPath("uploaded.file"));
>
> The form in the template file is with "enctype" set to
> "multipart/form-data".
> I have searched the archives but found no answer.

If you always want the files to be saved to disk than set

services.UploadService.automatic = true
services.UploadService.size.threshold = 0

Do you have these values set?


> Thanks in advance for any help I get!
> Gunter Miessbrandt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

--

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Problems with UploadService

Posted by Jason van Zyl <jv...@apache.org>.
On 8/23/01 10:28 AM, "Gunter Miessbrandt" <mi...@ixtern.de> wrote:

> Hi,
> I have problems with UploadService.
> When I try to upload a file FileItem
> often writes 0 bytes long file. The upload work fine as long as the file is
> a jpg-graphic. With other extensions it doesn?t work. Sometimes the
> jpg-files are only half loaded.
> My Turbine Version is 2.1.
> 
> Here's the code that I use to upload the file:
> FileItem fileItem =
> data.getParameters().getFileItem("file");
> fileItem.write(TurbineServlet.getRealPath("uploaded.file"));
> 
> The form in the template file is with "enctype" set to
> "multipart/form-data".
> I have searched the archives but found no answer.

If you always want the files to be saved to disk than set

services.UploadService.automatic = true
services.UploadService.size.threshold = 0

Do you have these values set?

 
> Thanks in advance for any help I get!
> Gunter Miessbrandt
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Problems with UploadService

Posted by Gunter Miessbrandt <mi...@ixtern.de>.
Hi,
I have problems with UploadService.
When I try to upload a file FileItem
often writes 0 bytes long file. The upload work fine as long as the file is
a jpg-graphic. With other extensions it doesn?t work. Sometimes the
jpg-files are only half loaded.
My Turbine Version is 2.1.

Here's the code that I use to upload the file:
FileItem fileItem =
data.getParameters().getFileItem("file");
fileItem.write(TurbineServlet.getRealPath("uploaded.file"));

The form in the template file is with "enctype" set to
"multipart/form-data".
I have searched the archives but found no answer.

Thanks in advance for any help I get!
Gunter Miessbrandt


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Problems with UploadService

Posted by Gunter Miessbrandt <mi...@ixtern.de>.
Hi,
I have problems with UploadService.
When I try to upload a file FileItem
writes 0 bytes long file. 
My Turbine Version is 2.1.

Here's the code that I use to upload the file:
FileItem fileItem =
data.getParameters().getFileItem("file");
fileItem.write(TurbineServlet.getRealPath("uploaded.file"));

The form in the template file is with "enctype" set to
"multipart/form-data".
I have searched the archives but found no answer.

Thanks in advance for any help I get!
Gunter Miessbrandt

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Cookie name is a reserved token

Posted by cm...@yahoo.com.
On Tue, 7 Aug 2001, Gareth Coltman wrote:

> I am  getting the following error trying to load test my app.
>
> I am looked at the bug database:
>
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=231
>
> and it claims this bug is fixed in Tomcat 3.3
>
> I am using tomcat 3.3/mod_jk with the pooled tcp connector,and I still get it.


Are you sure you're using 3.3 ? This stack trace is certainly not from
3.3, the org.apache.tomcat.session package was renamed to
o.a.t.modules.session.

I'm pretty sure I fixed the bug in 3.3, but if not - can you send me the
cookie ? Just add a println() in the session interceptor, before cookie
processing - and print all the headers, then send the "Cookie: ...."
header(s).

Costin

>
>
> java.lang.IllegalArgumentException: Cookie name
> Path is a reserved token
>         at javax.servlet.http.Cookie.<init>(Cookie.java:185)
>         at
> org.apache.tomcat.util.RequestUtil.processCookies(RequestUtil.java:189)
>         at
> org.apache.tomcat.core.RequestImpl.getCookieCount(RequestImpl.java:494)
>         at
> org.apache.tomcat.session.StandardSessionInterceptor.requestMap(StandardSess
> ionInterceptor.java:143)
>         at
> org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:820
> )
>         at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:77
> 1)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
>         at
> org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
> (Ajp12ConnectionHandler.java:166)
>         at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
>         at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>         at java.lang.Thread.run(Thread.java:484)
>
>


Cookie name is a reserved token

Posted by Gareth Coltman <ga...@majorband.co.uk>.
I am  getting the following error trying to load test my app.

I am looked at the bug database:

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=231

and it claims this bug is fixed in Tomcat 3.3 

I am using tomcat 3.3/mod_jk with the pooled tcp connector,and I still get it.

I have no idea why? Could be it be a threading issue? The server seems to have enough free resources...

Please help!!!!




java.lang.IllegalArgumentException: Cookie name
Path is a reserved token
        at javax.servlet.http.Cookie.<init>(Cookie.java:185)
        at
org.apache.tomcat.util.RequestUtil.processCookies(RequestUtil.java:189)
        at
org.apache.tomcat.core.RequestImpl.getCookieCount(RequestImpl.java:494)
        at
org.apache.tomcat.session.StandardSessionInterceptor.requestMap(StandardSess
ionInterceptor.java:143)
        at
org.apache.tomcat.core.ContextManager.processRequest(ContextManager.java:820
)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:77
1)
        at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:166)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
        at java.lang.Thread.run(Thread.java:484)

-- 
Mike Scott
Head of Technology Operations
rightmove.co.uk
Tel: 020 7821 9661  Mobile: 07941 576326  Email: Mike.Scott@rightmove.co.uk