You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Tom Eugelink <tb...@tbee.org> on 2005/04/20 11:07:21 UTC

FileUpoad:

Is it possible to access the form fields upon a file too large exception?

Tom

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
The exception is thrown serverside, so there is no problem.

On 4/20/05, José Antonio Pérez Testa <ja...@indra.es> wrote:
> IMO it depends on the position in the form. If the Part containing the
> hidden field is before the Part containing the broken file there is a
> chance to get it, if the exception is thrown before this part was
> processed there is no chance at all.
> 
> Tom Eugelink wrote:
> 
> >> A field value from the request?  In what you have below, the "field"
> >> apparently is in a GET, but you cannot use that for a file upload.
> >
> >
> > No, here is the form code in the jsp:
> >
> > <form enctype="multipart/form-data" method="post" action="PhotoUpload">
> > <input enctype="multipart/form-data" type="file" name="photo"/>
> > <input type="submit" value="Upload" name="upload"/>
> > <INPUT name="id" type="hidden" value="<%=request.getParameter("id")%>"/>
> > </form>
> >
> > There is a hidden field "id" that get's it value from the request that
> > opened the jsp. On error I need to reproduce that URL and add an error
> > code.
> >
> > So:
> >
> > http://xxx/upload.jsp?id=3
> >
> > will become
> >
> > http://xxx/upload.jsp?id=3&error=maxsize
> >
> > Tom
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
By the way, why not put the check before the parse, if I read the code
correctly?

On 4/21/05, Tom Eugelink <tb...@tbee.org> wrote:
> Thanks Dakota,
> 
> The solution was very simple:
> 
> ...
> 
>         // we always want to be able to get the ID
>         // so we do the filesize check ourselves
>          int lRequestSize = request.getContentLength();
>         lFileUpload.setSizeMax(lRequestSize);
> 
> ...
> 
>         lFileItems = lFileUpload.parseRequest(request);
> 
> ...
>         //
>         // manually check the size
>          if (iMaxSize >= 0 && lRequestSize > iMaxSize)
>          {
>                 response.sendRedirect(iOnError + "?id=" + lId);
>                 return;
>          }
> 
> Great help.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
> My example of what I am doing is not taking over the parsing.  Rather,
> it is just providing a wrapper to get the functionality I need, which
> is, I think, what you probably need.

Correct. I let the library do its thing, I just need a way to get to the 
list after it decides that an exception should be thrown (but the 
parsing is done already).

Tom

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


Re: FileUpoad:

Posted by Martin Cooper <mf...@gmail.com>.
The solution below works only if you are prepared to store as much
data as the client wants to send. However, the size check in
FileUpload is designed to prevent exactly that.

If the client wants to upload a 2GB file, and you use the code below,
then you'd better have 2GB available to store that request, because
parseRequest() won't return until it's done parsing all that data. The
point of the size check in FileUpload is so that FileUpload knows when
to ignore the incoming stream. (Unfortunately, the container will
continue to receive it, but that's a separate issue.)

To answer your original question in this thread, no, it's not
currently possible to access items prior to one that blows the limit.
However, I can see how that might be useful in some constrained
situations, so feel free to file an enhancement request in the bug
database for that.

--
Martin Cooper


On 4/21/05, Tom Eugelink <tb...@tbee.org> wrote:
> Thanks Dakota,
> 
> The solution was very simple:
> 
> ...
> 
>         // we always want to be able to get the ID
>         // so we do the filesize check ourselves
>          int lRequestSize = request.getContentLength();
>         lFileUpload.setSizeMax(lRequestSize);
> 
> ...
> 
>         lFileItems = lFileUpload.parseRequest(request);
> 
> ...
>         //
>         // manually check the size
>          if (iMaxSize >= 0 && lRequestSize > iMaxSize)
>          {
>                 response.sendRedirect(iOnError + "?id=" + lId);
>                 return;
>          }
> 
> Great help.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
Good show.  Ask for a raise.  ///;-)

On 4/21/05, Tom Eugelink <tb...@tbee.org> wrote:
> Thanks Dakota,
> 
> The solution was very simple:
> 
> ...
> 
>         // we always want to be able to get the ID
>         // so we do the filesize check ourselves
>          int lRequestSize = request.getContentLength();
>         lFileUpload.setSizeMax(lRequestSize);
> 
> ...
> 
>         lFileItems = lFileUpload.parseRequest(request);
> 
> ...
>         //
>         // manually check the size
>          if (iMaxSize >= 0 && lRequestSize > iMaxSize)
>          {
>                 response.sendRedirect(iOnError + "?id=" + lId);
>                 return;
>          }
> 
> Great help.
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
Thanks Dakota,

The solution was very simple:

...

     	// we always want to be able to get the ID
     	// so we do the filesize check ourselves
         int lRequestSize = request.getContentLength();
     	lFileUpload.setSizeMax(lRequestSize);

...

  	lFileItems = lFileUpload.parseRequest(request);

...
	//
	// manually check the size
         if (iMaxSize >= 0 && lRequestSize > iMaxSize)
         {
     		response.sendRedirect(iOnError + "?id=" + lId);
     		return;
         }

Great help.

Tom

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
My example of what I am doing is not taking over the parsing.  Rather,
it is just providing a wrapper to get the functionality I need, which
is, I think, what you probably need.

On 4/20/05, Tom Eugelink <tb...@tbee.org> wrote:
> > Well, if you want the id earlier, get it earlier?
> 
> Yeah. Okay. I could of course parse the request myself, but I've decided
> to use the FileUpload library and I assume there is a way to do this
> using the file upload library.
> 
> 
> > Also, there are all
> > sorts of things you can do by extending the commons classes, e.g. I
> > drop a monitor in as follows:
> 
> Which probably is where I'm heading. I need a way to fetched the parsed
> list even if the exception occured. But for some reason I assumed that
> there probably are other people that also need the fields, even if the
> file is too large, so I figured there must de a standard solution. But
> appearantly not.
> 
> Thanks for the help!
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
> Well, if you want the id earlier, get it earlier?  

Yeah. Okay. I could of course parse the request myself, but I've decided 
to use the FileUpload library and I assume there is a way to do this 
using the file upload library.


> Also, there are all
> sorts of things you can do by extending the commons classes, e.g. I
> drop a monitor in as follows:

Which probably is where I'm heading. I need a way to fetched the parsed 
list even if the exception occured. But for some reason I assumed that 
there probably are other people that also need the fields, even if the 
file is too large, so I figured there must de a standard solution. But 
appearantly not.

Thanks for the help!

Tom

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
Well, if you want the id earlier, get it earlier?  Also, there are all
sorts of things you can do by extending the commons classes, e.g. I
drop a monitor in as follows:

public class UploadFileItemFactory
    extends DefaultFileItemFactory {
  private List monitors;
  private int  contentLength;

  public UploadFileItemFactory() {
  }

  public FileItem createItem(String  fieldName,
                             String  contentType,
                             boolean isFormField,
                             String  fileName) {
    return new UploadFileItem(fieldName,
                              contentType,
                              isFormField,
                              fileName,
                              monitors,
                              getRepository(),
                              getSizeThreshold(),
                              contentLength);
  }

  public void setContentLength(int contentLength) {
    this.contentLength = contentLength;
  }

  public int  getContentLength() {
    return contentLength;
  }

  public void setMonitors(List monitors) {
    this.monitors = monitors;
  }

  public List getMonitors() {
    return this.monitors;
  }
}

And this allows stuff like follows:


    UploadFileItemFactory ufiFactory = new UploadFileItemFactory();

    ufiFactory.setMonitors(monitors);
    ufiFactory.setContentLength(req.getContentLength());

    DiskFileUpload dfu = new DiskFileUpload();

    dfu.setFileItemFactory(ufiFactory);
    dfu.setSizeMax(maxFileSize);
    dfu.setSizeThreshold(Upload.BUFFER_SIZE);
    dfu.setRepositoryPath(repositoryPath);

    if(encoding != null) {
      dfu.setHeaderEncoding(encoding);
    }

    List list = null;

    try {
      list = dfu.parseRequest(req);
    } catch(FileUploadException cfue) {
      throw new IOException(cfue.getMessage());
    }

    Object obj = null;

    for(Iterator iterator = list.iterator(); iterator.hasNext();) {
        FileItem fi        = (FileItem)iterator.next();
        String   fieldName = fi.getFieldName();

      if(fi.isFormField()) {
        String data = null;
        if(encoding != null) {
          data = fi.getString(encoding);
        } else {
          data = fi.getString();
        }

        List names = (List)parameterNames.get(fieldName);

        if(names == null) {
          names =  Collections.synchronizedList(new LinkedList());
          parameterNames.put(fieldName, names);
        }

        names.add(data);
      } else {
        String name        = fi.getName();
        String ext         = name;
        String contentType = null;
        int    flag        = -99;
        if(name != null) {
          MultipartFile mf = new UploadMultipartFile(fi);
          mf.setName(name);
          mf.setContentType(contentType = fi.getContentType());
          mf.setSize(fi.getSize());
          files.put(fieldName, mf);

          //---------------Take care of mime map for downloads------------------
          flag = ext.lastIndexOf('.');
          ext  = ext.substring(flag + 1);
          if(flag != -1 && "".equals(mime_map.getProperty(ext))) {
            mime_map.setProperty(ext,contentType);
            LoadMimes.setMimes(mime_map);
          }
          //--------------------------------------------------------------------
        }
      }
    }
  }

Get what I mean?

On 4/20/05, Tom Eugelink <tb...@tbee.org> wrote:
> > No, don't agree.  Show me the code that you use to farm the data.  I
> > assume you are using Commons fileupload.  But, how you do it is what
> > makes a difference.  This stuff about the position on the form can be
> > discussed later.  No sense letting a great philosophical discussion
> > get in the way of getting something done.  ///;-)
> 
> Agree.
> 
>         // Check that we have a file upload request
>         if (!FileUpload.isMultipartContent(request))
>         {
>                         ServletException lServletException = new ServletException("Only file
> uploads are accepted to this URL");
>                         log4j.error(lServletException);
>                         throw lServletException;
>         }
> 
>         // Create a new file upload handler
>         DiskFileUpload lFileUpload = new DiskFileUpload();
>         lFileUpload.setSizeThreshold(iMaxSize);
>         lFileUpload.setSizeMax(iMaxSize);
>         lFileUpload.setRepositoryPath(iTmpDir.getAbsolutePath());
> 
>         //
>         // Parse the request
>         List lFileItems = null;
>         try
>                 {
>                 lFileItems = lFileUpload.parseRequest(request);
>                 }
>         catch (FileUploadException e)
>                 {
>                 response.sendRedirect(iOnError + "?error=parse&info=Bestand is te
> groot");
>                 return;
>                 }
> 
>         //
>         // get the ID
>         FileItem lIdFileItem = getFileItemFromList(lFileItems, "id");
> 
> As you can see the sendRedirect occurs before I get the id...
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
> No, don't agree.  Show me the code that you use to farm the data.  I
> assume you are using Commons fileupload.  But, how you do it is what
> makes a difference.  This stuff about the position on the form can be
> discussed later.  No sense letting a great philosophical discussion
> get in the way of getting something done.  ///;-)

Agree.

     	// Check that we have a file upload request
     	if (!FileUpload.isMultipartContent(request))
     	{
			ServletException lServletException = new ServletException("Only file 
uploads are accepted to this URL");
			log4j.error(lServletException);
			throw lServletException;
     	}
     	
     	// Create a new file upload handler
     	DiskFileUpload lFileUpload = new DiskFileUpload();
     	lFileUpload.setSizeThreshold(iMaxSize);
     	lFileUpload.setSizeMax(iMaxSize);
     	lFileUpload.setRepositoryPath(iTmpDir.getAbsolutePath());
     	
     	//
     	// Parse the request
     	List lFileItems = null;
     	try
		{
     		lFileItems = lFileUpload.parseRequest(request);
		}
     	catch (FileUploadException e)
		{
     		response.sendRedirect(iOnError + "?error=parse&info=Bestand is te 
groot");
     		return;
		}

     	//
     	// get the ID
     	FileItem lIdFileItem = getFileItemFromList(lFileItems, "id");


As you can see the sendRedirect occurs before I get the id...

Tom

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


Re: [validator] Resource bundle with standalone validation

Posted by Matt Goodwin <mg...@metalexis.com>.
There is a good discussion of that on the Commons-Validator site.   If 
you're in a web environment you basically initilalize your resource 
bundle in an initialization servlet.  Check out this link. 
http://wiki.apache.org/jakarta-commons/ValidatorStandalone.  If you need 
an example of the code I can send you what I've done.  If you're outside 
the web environment there are a few other things that you can do, but I 
will let others speak on that as I have not done that.

Thanks,

Matt

Ben Avery wrote:

> I want to use a resource bundle to generate meaningful error messages, 
> using Validator in a standalone, non-Struts environment.
>
> What do I need to put in the Java class which instantiates and calls 
> the Validator, so it understands which resourcebundle file to look up 
> references like
>
> xml config file:
> ...
> <global>
>     <validator
>       name="email"
>       classname="org.youthnet.ben.ValidatorWrapper"
>       method="doValidEmail"
>       methodParams="java.lang.Object, org.apache.commons.validator.Field"
>       msg="errors.email"/>
> ...
> </global>
>
> <formset>
>   <form name="simpleform">
>      <field property="startDate" depends="required">
>         <arg position="0" key="Start date"/>
>      </field>
> ...
>   </form>
> </formset>
> ...
>
> the resource file would look like:
>
> errors.required={0} is required.
> errors.maxlength={0} cannot be greater than {1} characters.
> errors.email={0} is an invalid email address.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>

-- 
Matt Goodwin
mgoodwin@metalexis.com
(515)708-0114
Metalexis
"Transcending the Ordinary"


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


[validator] Resource bundle with standalone validation

Posted by Ben Avery <be...@youthnetuk.org>.
I want to use a resource bundle to generate meaningful error messages, 
using Validator in a standalone, non-Struts environment.

What do I need to put in the Java class which instantiates and calls the 
Validator, so it understands which resourcebundle file to look up 
references like

xml config file:
...
<global>
     <validator
       name="email"
       classname="org.youthnet.ben.ValidatorWrapper"
       method="doValidEmail"
       methodParams="java.lang.Object, org.apache.commons.validator.Field"
       msg="errors.email"/>
...
</global>

<formset>
   <form name="simpleform">
      <field property="startDate" depends="required">
         <arg position="0" key="Start date"/>
      </field>
...
   </form>
</formset>
...

the resource file would look like:

errors.required={0} is required.
errors.maxlength={0} cannot be greater than {1} characters.
errors.email={0} is an invalid email address.

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
No, don't agree.  Show me the code that you use to farm the data.  I
assume you are using Commons fileupload.  But, how you do it is what
makes a difference.  This stuff about the position on the form can be
discussed later.  No sense letting a great philosophical discussion
get in the way of getting something done.  ///;-)

On 4/20/05, Tom Eugelink <tb...@tbee.org> wrote:
> > IMO it depends on the position in the form. If the Part containing the
> > hidden field is before the Part containing the broken file there is a
> > chance to get it, if the exception is thrown before this part was
> > processed there is no chance at all.
> 
> Ok. But I feel that would not be a "production quality" solution, since
> the sequence is not specified anywhere and using a different browser...
> Secondly, that would mean I have to parse the request myself (and there
> is a reason why I use the library :-).
> 
> So the praktical answer would be "no", I guess.
> Agree?
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
> IMO it depends on the position in the form. If the Part containing the 
> hidden field is before the Part containing the broken file there is a
> chance to get it, if the exception is thrown before this part was 
> processed there is no chance at all.

Ok. But I feel that would not be a "production quality" solution, since 
the sequence is not specified anywhere and using a different browser... 
Secondly, that would mean I have to parse the request myself (and there 
is a reason why I use the library :-).

So the praktical answer would be "no", I guess.
Agree?

Tom

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


Re: FileUpoad:

Posted by José Antonio Pérez Testa <ja...@indra.es>.
IMO it depends on the position in the form. If the Part containing the 
hidden field is before the Part containing the broken file there is a
chance to get it, if the exception is thrown before this part was 
processed there is no chance at all.

Tom Eugelink wrote:

>> A field value from the request?  In what you have below, the "field"
>> apparently is in a GET, but you cannot use that for a file upload.
>
>
> No, here is the form code in the jsp:
>
> <form enctype="multipart/form-data" method="post" action="PhotoUpload">
> <input enctype="multipart/form-data" type="file" name="photo"/>
> <input type="submit" value="Upload" name="upload"/>
> <INPUT name="id" type="hidden" value="<%=request.getParameter("id")%>"/>
> </form>
>
> There is a hidden field "id" that get's it value from the request that 
> opened the jsp. On error I need to reproduce that URL and add an error 
> code.
>
> So:
>
> http://xxx/upload.jsp?id=3
>
> will become
>
> http://xxx/upload.jsp?id=3&error=maxsize
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
> A field value from the request?  In what you have below, the "field"
> apparently is in a GET, but you cannot use that for a file upload.

No, here is the form code in the jsp:

<form enctype="multipart/form-data" method="post" action="PhotoUpload">
<input enctype="multipart/form-data" type="file" name="photo"/>
<input type="submit" value="Upload" name="upload"/>
<INPUT name="id" type="hidden" value="<%=request.getParameter("id")%>"/>
</form>

There is a hidden field "id" that get's it value from the request that 
opened the jsp. On error I need to reproduce that URL and add an error code.

So:

http://xxx/upload.jsp?id=3

will become

http://xxx/upload.jsp?id=3&error=maxsize

Tom

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
<SNIP>
> The problem: during the FileUpload, parse(...) throws a
> FileUploadException if the file exceeds maxsize. In order to handle this
> situation I want to do a forward/redirect, but for the URL I need a
> field value.
</SNIP>

A field value from the request?  In what you have below, the "field"
apparently is in a GET, but you cannot use that for a file upload.

<SNIP>
> In steps:
> - upload.jsp?id=XXXX, in the jsp a hidden field contains the id
> - UploadServlet gets file and id
> - upon error I want to forward to upload.jsp, with an error and the id
> 
> So I need the ID in the servlet when the FileUploadException is thrown.
> 
> Better? :-)
</SNIP>

I would have to look at your code in some more detail to see what is
up.  You can always catch an exception and do whatever you want, but
how you do this depends on the code.  Care to show the code a bit so
we can see what the situation is?


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: FileUpoad:

Posted by Tom Eugelink <tb...@tbee.org>.
Very good (I posted the question before, so I decided to go with a short 
version this time ;-).

The problem: during the FileUpload, parse(...) throws a 
FileUploadException if the file exceeds maxsize. In order to handle this 
situation I want to do a forward/redirect, but for the URL I need a 
field value.

In steps:
- upload.jsp?id=XXXX, in the jsp a hidden field contains the id
- UploadServlet gets file and id
- upon error I want to forward to upload.jsp, with an error and the id

So I need the ID in the servlet when the FileUploadException is thrown.

Better? :-)

Many thanks!

Tom


Dakota Jack wrote:
> Not sure what this question is, Tom.  If you can enunciate what you
> are asking, I probably can answer the question.
> 
> On 4/20/05, Tom Eugelink <tb...@tbee.org> wrote:
> 
>>Is it possible to access the form fields upon a file too large exception?
>>
>>Tom
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 
> 
> 

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


Re: FileUpoad:

Posted by Dakota Jack <da...@gmail.com>.
Not sure what this question is, Tom.  If you can enunciate what you
are asking, I probably can answer the question.

On 4/20/05, Tom Eugelink <tb...@tbee.org> wrote:
> Is it possible to access the form fields upon a file too large exception?
> 
> Tom
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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