servletFile upload: javax.servlet,servlet throws exception

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

servletFile upload: javax.servlet,servlet throws exception

Vasileios.Kantartzis
Hello all,
I am trying to wrap the servlet request method as described in the
documentation to extract form field information and the actual file
submitted .
I am using the ServletFileUpload class in order to extract the desiered
information  as follows;
ServletFileUpload servlet = new ServletFileupload(factory) // a factory
instance
Servlet.parseRequest(request); // the httpRequest.

At this point I get the following exception:
Sevlet execution threw an exception

With a reference to a code line number 116 in ServletFileUpload.java

Does any one have a suggestion please ?
How should I get the requested form fields ?





V.(Billy) Kantartzis
Surveilance & Reconnaissance Recource Centre
Command & Control Systems Devision
T:+31(0)70374-3706
F: +31(0)70374-3079
E:[hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: servletFile upload: javax.servlet,servlet throws exception

Martin Cooper
On 8/25/05, [hidden email]
<[hidden email]> wrote:

> Hello all,
> I am trying to wrap the servlet request method as described in the
> documentation to extract form field information and the actual file
> submitted .
> I am using the ServletFileUpload class in order to extract the desiered
> information  as follows;
> ServletFileUpload servlet = new ServletFileupload(factory) // a factory
> instance
> Servlet.parseRequest(request); // the httpRequest.
>
> At this point I get the following exception:
> Sevlet execution threw an exception
>
> With a reference to a code line number 116 in ServletFileUpload.java

You'll need to provide us with more information than that. That line
of code is simply a call to another parseRequest() method, so I can't
tell anything about what's going wrong from just that.

--
Martin Cooper


> Does any one have a suggestion please ?
> How should I get the requested form fields ?
>
>
>
>
>
> V.(Billy) Kantartzis
> Surveilance & Reconnaissance Recource Centre
> Command & Control Systems Devision
> T:+31(0)70374-3706
> F: +31(0)70374-3079
> E:[hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: servletFile upload: javax.servlet,servlet throws exception

Vasileios.Kantartzis
In reply to this post by Vasileios.Kantartzis

I managed to solve the problem using the DiskFileUpload object
Using the parse request method provided. How would it be possible to do
the same using ServletFile upload?
Just make an instance othe object and pass my request reference wouldn't
that work? I would like to use the ServletFileUpload since
DiskFileUpload  seems to be deprecated.
Thank you
-----Original Message-----
From: Martin Cooper [mailto:[hidden email]]
Sent: 25 August 2005 22:24
To: Jakarta Commons Users List
Subject: Re: servletFile upload: javax.servlet,servlet throws exception

On 8/25/05, [hidden email]
<[hidden email]> wrote:
> Hello all,
> I am trying to wrap the servlet request method as described in the
> documentation to extract form field information and the actual file
> submitted .
> I am using the ServletFileUpload class in order to extract the
desiered
> information  as follows;
> ServletFileUpload servlet = new ServletFileupload(factory) // a
factory
> instance
> Servlet.parseRequest(request); // the httpRequest.
>
> At this point I get the following exception:
> Sevlet execution threw an exception
>
> With a reference to a code line number 116 in ServletFileUpload.java

You'll need to provide us with more information than that. That line
of code is simply a call to another parseRequest() method, so I can't
tell anything about what's going wrong from just that.

--
Martin Cooper


> Does any one have a suggestion please ?
> How should I get the requested form fields ?
>
>
>
>
>
> V.(Billy) Kantartzis
> Surveilance & Reconnaissance Recource Centre
> Command & Control Systems Devision
> T:+31(0)70374-3706
> F: +31(0)70374-3079
> E:[hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: servletFile upload: javax.servlet,servlet throws exception

Brian Cook


I have been wondering about this too.  I also just noticed
DiskFileUpload has been deprecated and the replacement classes listed do
not seem to have the same functionality.  Are there plans for an update
to the user guides?


[hidden email] wrote:

> I managed to solve the problem using the DiskFileUpload object
> Using the parse request method provided. How would it be possible to do
> the same using ServletFile upload?
> Just make an instance othe object and pass my request reference wouldn't
> that work? I would like to use the ServletFileUpload since
> DiskFileUpload  seems to be deprecated.
> Thank you
> -----Original Message-----
> From: Martin Cooper [mailto:[hidden email]]
> Sent: 25 August 2005 22:24
> To: Jakarta Commons Users List
> Subject: Re: servletFile upload: javax.servlet,servlet throws exception
>
> On 8/25/05, [hidden email]
> <[hidden email]> wrote:
>
>>Hello all,
>>I am trying to wrap the servlet request method as described in the
>>documentation to extract form field information and the actual file
>>submitted .
>>I am using the ServletFileUpload class in order to extract the
>
> desiered
>
>>information  as follows;
>>ServletFileUpload servlet = new ServletFileupload(factory) // a
>
> factory
>
>>instance
>>Servlet.parseRequest(request); // the httpRequest.
>>
>>At this point I get the following exception:
>>Sevlet execution threw an exception
>>
>>With a reference to a code line number 116 in ServletFileUpload.java
>
>
> You'll need to provide us with more information than that. That line
> of code is simply a call to another parseRequest() method, so I can't
> tell anything about what's going wrong from just that.
>
> --
> Martin Cooper
>
>
>
>>Does any one have a suggestion please ?
>>How should I get the requested form fields ?
>>
>>
>>
>>
>>
>>V.(Billy) Kantartzis
>>Surveilance & Reconnaissance Recource Centre
>>Command & Control Systems Devision
>>T:+31(0)70374-3706
>>F: +31(0)70374-3079
>>E:[hidden email]
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Brian Cook
Digital Services Analyst
Print Time Inc.
[hidden email]
913.345.8900


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: servletFile upload: javax.servlet,servlet throws exception

Martin Cooper
On 8/26/05, Brian Cook <[hidden email]> wrote:
>
>
>
> I have been wondering about this too. I also just noticed
> DiskFileUpload has been deprecated and the replacement classes listed do
> not seem to have the same functionality. Are there plans for an update
> to the user guides?


FileItemFactory factory = new DiskFileItemFactory();
// Configure the factory if you need to
FileUpload upload = new ServletFileUpload(factory);
List items = upload.parseRequest();

This is only available in the nightly builds at this point.

The reason for the changes is that the environment (servlet or portlet) is
orthogonal to what you want to do with the content of the items. The old (
1.0) code was servlet only, and largely disk only. What I'm trying to do
with 1.1 is have one core implementation that just handles the process, and
then provide for servlet and portlet environments as well as disk, database,
or whatever, means of managing the uploaded data.

Hope this helps.

--
Martin Cooper


[hidden email] wrote:

> > I managed to solve the problem using the DiskFileUpload object
> > Using the parse request method provided. How would it be possible to do
> > the same using ServletFile upload?
> > Just make an instance othe object and pass my request reference wouldn't
> > that work? I would like to use the ServletFileUpload since
> > DiskFileUpload seems to be deprecated.
> > Thank you
> > -----Original Message-----
> > From: Martin Cooper [mailto:[hidden email]]
> > Sent: 25 August 2005 22:24
> > To: Jakarta Commons Users List
> > Subject: Re: servletFile upload: javax.servlet,servlet throws exception
> >
> > On 8/25/05, [hidden email]
> > <[hidden email]> wrote:
> >
> >>Hello all,
> >>I am trying to wrap the servlet request method as described in the
> >>documentation to extract form field information and the actual file
> >>submitted .
> >>I am using the ServletFileUpload class in order to extract the
> >
> > desiered
> >
> >>information as follows;
> >>ServletFileUpload servlet = new ServletFileupload(factory) // a
> >
> > factory
> >
> >>instance
> >>Servlet.parseRequest(request); // the httpRequest.
> >>
> >>At this point I get the following exception:
> >>Sevlet execution threw an exception
> >>
> >>With a reference to a code line number 116 in ServletFileUpload.java
> >
> >
> > You'll need to provide us with more information than that. That line
> > of code is simply a call to another parseRequest() method, so I can't
> > tell anything about what's going wrong from just that.
> >
> > --
> > Martin Cooper
> >
> >
> >
> >>Does any one have a suggestion please ?
> >>How should I get the requested form fields ?
> >>
> >>
> >>
> >>
> >>
> >>V.(Billy) Kantartzis
> >>Surveilance & Reconnaissance Recource Centre
> >>Command & Control Systems Devision
> >>T:+31(0)70374-3706
> >>F: +31(0)70374-3079
> >>E:[hidden email]
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [hidden email]
> >>For additional commands, e-mail: [hidden email]
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
> --
> Brian Cook
> Digital Services Analyst
> Print Time Inc.
> [hidden email]
> 913.345.8900
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

HttpServletRequest processing

Mashama McFarlane
I need some help. I am working with file uploads. The ideal file uploads
will be large enough to justify a file upload progress indicator. I am
trying to figure out the easiest way of doing this, but it is much more
complicated than I originally thought. It would be nice if somebody out
there can prove me wrong on that point. I know that if I can monitor the
request as it comes into the servlet container, then I can extract out the
content-length and then everything else is a matter of counting bytes, but
where and how do I do this. This cannot happen in the servlet as, I am
assuming, the whole request has been received in its entirity prior the
servlet servicing the request. So where on the totem pole need I be. Please
advise.
Reply | Threaded
Open this post in threaded view
|

Re: HttpServletRequest processing

Frank W. Zammetti
Hi,

There really is no straight-forward way of doing this.  In theory it
goes against the basic nature of HTTP.

That being said, Michael McGrady implemented such a solution, and
hopefully he will see this and be able to talk about it.  I'll do my
best to remember the basic theory...

You start by targeting your form submission to a new window.  This is
where your progress bar will display.  In your servlet that recieves the
request that contains the file upload, you spawn a new thread to handle
the upload and return immediately with a page with some Javascript to
periodically poll the servlet to get the progress of the upload (every 5
seconds for example).  The servlet of course has to retain a reference
to the thread handling the upload, and it has to have some sort of
unique identifier to be able to request the status update.  This
identifier is passed to the servlet from the progress window.  Once the
upload completes, a page is returned to inform the user (might be in the
popup still, might be a page that redirects the parent window of the
popup to a completion page).

Michael will hopefully correct me or expand on this as appropriate, but
that's what I recall being the basic theory behind his approach.  I
think his code was on the Struts Wiki at one point, you may want to go
have a look and see.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

Mashama McFarlane wrote:

> I need some help. I am working with file uploads. The ideal file uploads
> will be large enough to justify a file upload progress indicator. I am
> trying to figure out the easiest way of doing this, but it is much more
> complicated than I originally thought. It would be nice if somebody out
> there can prove me wrong on that point. I know that if I can monitor the
> request as it comes into the servlet container, then I can extract out the
> content-length and then everything else is a matter of counting bytes, but
> where and how do I do this. This cannot happen in the servlet as, I am
> assuming, the whole request has been received in its entirity prior the
> servlet servicing the request. So where on the totem pole need I be. Please
> advise.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: HttpServletRequest processing

Mashama McFarlane
Thanks a lot. Actually this is exactly what I was envisioning but my
problems is that I don' know what type of thread to write to handle the
upload. I mean I am pretty sure I can't write a servlet thread because I am
assuming that the servlet container only passes the servlet the request
after it has received it in its entirety. Please correct me if I am wrong,
but if this is correct then any solution must be at the container level. So
the question is what kind of thread? At what level? And is it even possible?
Thanks for your help.

Sincerely,
Mashama

On 9/1/05, Frank W. Zammetti <[hidden email]> wrote:

>
> Hi,
>
> There really is no straight-forward way of doing this. In theory it
> goes against the basic nature of HTTP.
>
> That being said, Michael McGrady implemented such a solution, and
> hopefully he will see this and be able to talk about it. I'll do my
> best to remember the basic theory...
>
> You start by targeting your form submission to a new window. This is
> where your progress bar will display. In your servlet that recieves the
> request that contains the file upload, you spawn a new thread to handle
> the upload and return immediately with a page with some Javascript to
> periodically poll the servlet to get the progress of the upload (every 5
> seconds for example). The servlet of course has to retain a reference
> to the thread handling the upload, and it has to have some sort of
> unique identifier to be able to request the status update. This
> identifier is passed to the servlet from the progress window. Once the
> upload completes, a page is returned to inform the user (might be in the
> popup still, might be a page that redirects the parent window of the
> popup to a completion page).
>
> Michael will hopefully correct me or expand on this as appropriate, but
> that's what I recall being the basic theory behind his approach. I
> think his code was on the Struts Wiki at one point, you may want to go
> have a look and see.
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
> Mashama McFarlane wrote:
> > I need some help. I am working with file uploads. The ideal file uploads
> > will be large enough to justify a file upload progress indicator. I am
> > trying to figure out the easiest way of doing this, but it is much more
> > complicated than I originally thought. It would be nice if somebody out
> > there can prove me wrong on that point. I know that if I can monitor the
> > request as it comes into the servlet container, then I can extract out
> the
> > content-length and then everything else is a matter of counting bytes,
> but
> > where and how do I do this. This cannot happen in the servlet as, I am
> > assuming, the whole request has been received in its entirity prior the
> > servlet servicing the request. So where on the totem pole need I be.
> Please
> > advise.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: HttpServletRequest processing

Frank W. Zammetti
Well, I would defer to Michael to answer this, as I don't know the
answer myself, I'd have to go research and figure it out.  One thing
that comes to mind though is doing it with a filter (with a
RequestWrapper involved I would think) so you would have access to the
request "as it forms", so to speak.  You would spawn a new thread from
the filter, giving is a reference to the wrapper, and continue
processing from there.

That being said, I do not recall his solution being filter-based, so
there must be another (probably simpler) answer.

Frank

Mashama McFarlane wrote:

> Thanks a lot. Actually this is exactly what I was envisioning but my
> problems is that I don' know what type of thread to write to handle the
> upload. I mean I am pretty sure I can't write a servlet thread because I am
> assuming that the servlet container only passes the servlet the request
> after it has received it in its entirety. Please correct me if I am wrong,
> but if this is correct then any solution must be at the container level. So
> the question is what kind of thread? At what level? And is it even possible?
> Thanks for your help.
>
> Sincerely,
> Mashama
>
> On 9/1/05, Frank W. Zammetti <[hidden email]> wrote:
>
>>Hi,
>>
>>There really is no straight-forward way of doing this. In theory it
>>goes against the basic nature of HTTP.
>>
>>That being said, Michael McGrady implemented such a solution, and
>>hopefully he will see this and be able to talk about it. I'll do my
>>best to remember the basic theory...
>>
>>You start by targeting your form submission to a new window. This is
>>where your progress bar will display. In your servlet that recieves the
>>request that contains the file upload, you spawn a new thread to handle
>>the upload and return immediately with a page with some Javascript to
>>periodically poll the servlet to get the progress of the upload (every 5
>>seconds for example). The servlet of course has to retain a reference
>>to the thread handling the upload, and it has to have some sort of
>>unique identifier to be able to request the status update. This
>>identifier is passed to the servlet from the progress window. Once the
>>upload completes, a page is returned to inform the user (might be in the
>>popup still, might be a page that redirects the parent window of the
>>popup to a completion page).
>>
>>Michael will hopefully correct me or expand on this as appropriate, but
>>that's what I recall being the basic theory behind his approach. I
>>think his code was on the Struts Wiki at one point, you may want to go
>>have a look and see.
>>
>>--
>>Frank W. Zammetti
>>Founder and Chief Software Architect
>>Omnytex Technologies
>>http://www.omnytex.com
>>
>>Mashama McFarlane wrote:
>>
>>>I need some help. I am working with file uploads. The ideal file uploads
>>>will be large enough to justify a file upload progress indicator. I am
>>>trying to figure out the easiest way of doing this, but it is much more
>>>complicated than I originally thought. It would be nice if somebody out
>>>there can prove me wrong on that point. I know that if I can monitor the
>>>request as it comes into the servlet container, then I can extract out
>>
>>the
>>
>>>content-length and then everything else is a matter of counting bytes,
>>
>>but
>>
>>>where and how do I do this. This cannot happen in the servlet as, I am
>>>assuming, the whole request has been received in its entirity prior the
>>>servlet servicing the request. So where on the totem pole need I be.
>>
>>Please
>>
>>>advise.
>>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>
>

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: HttpServletRequest processing

Mashama McFarlane
Thanks. That is an excellent idea. This is exactly what I need, to have
access to the request "as it forms". I am not sure if doing it with a filter
is exactly what I need because I was under the impression that a filter is
essentially a servlet from the containers perspective, but I am far from an
expert in this. I am looking forward hearing from Michael on this matter.

Sincerely,
Mashama

On 9/2/05, Frank W. Zammetti <[hidden email]> wrote:

>
> Well, I would defer to Michael to answer this, as I don't know the
> answer myself, I'd have to go research and figure it out. One thing
> that comes to mind though is doing it with a filter (with a
> RequestWrapper involved I would think) so you would have access to the
> request "as it forms", so to speak. You would spawn a new thread from
> the filter, giving is a reference to the wrapper, and continue
> processing from there.
>
> That being said, I do not recall his solution being filter-based, so
> there must be another (probably simpler) answer.
>
> Frank
>
> Mashama McFarlane wrote:
> > Thanks a lot. Actually this is exactly what I was envisioning but my
> > problems is that I don' know what type of thread to write to handle the
> > upload. I mean I am pretty sure I can't write a servlet thread because I
> am
> > assuming that the servlet container only passes the servlet the request
> > after it has received it in its entirety. Please correct me if I am
> wrong,
> > but if this is correct then any solution must be at the container level.
> So
> > the question is what kind of thread? At what level? And is it even
> possible?
> > Thanks for your help.
> >
> > Sincerely,
> > Mashama
> >
> > On 9/1/05, Frank W. Zammetti <[hidden email]> wrote:
> >
> >>Hi,
> >>
> >>There really is no straight-forward way of doing this. In theory it
> >>goes against the basic nature of HTTP.
> >>
> >>That being said, Michael McGrady implemented such a solution, and
> >>hopefully he will see this and be able to talk about it. I'll do my
> >>best to remember the basic theory...
> >>
> >>You start by targeting your form submission to a new window. This is
> >>where your progress bar will display. In your servlet that recieves the
> >>request that contains the file upload, you spawn a new thread to handle
> >>the upload and return immediately with a page with some Javascript to
> >>periodically poll the servlet to get the progress of the upload (every 5
> >>seconds for example). The servlet of course has to retain a reference
> >>to the thread handling the upload, and it has to have some sort of
> >>unique identifier to be able to request the status update. This
> >>identifier is passed to the servlet from the progress window. Once the
> >>upload completes, a page is returned to inform the user (might be in the
> >>popup still, might be a page that redirects the parent window of the
> >>popup to a completion page).
> >>
> >>Michael will hopefully correct me or expand on this as appropriate, but
> >>that's what I recall being the basic theory behind his approach. I
> >>think his code was on the Struts Wiki at one point, you may want to go
> >>have a look and see.
> >>
> >>--
> >>Frank W. Zammetti
> >>Founder and Chief Software Architect
> >>Omnytex Technologies
> >>http://www.omnytex.com
> >>
> >>Mashama McFarlane wrote:
> >>
> >>>I need some help. I am working with file uploads. The ideal file
> uploads
> >>>will be large enough to justify a file upload progress indicator. I am
> >>>trying to figure out the easiest way of doing this, but it is much more
> >>>complicated than I originally thought. It would be nice if somebody out
> >>>there can prove me wrong on that point. I know that if I can monitor
> the
> >>>request as it comes into the servlet container, then I can extract out
> >>
> >>the
> >>
> >>>content-length and then everything else is a matter of counting bytes,
> >>
> >>but
> >>
> >>>where and how do I do this. This cannot happen in the servlet as, I am
> >>>assuming, the whole request has been received in its entirity prior the
> >>>servlet servicing the request. So where on the totem pole need I be.
> >>
> >>Please
> >>
> >>>advise.
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [hidden email]
> >>For additional commands, e-mail: [hidden email]
> >>
> >>
> >
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>