users@jersey.java.net

Re: [Jersey] Problem while deploying my Jersey application

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 24 Nov 2009 14:08:15 +0100

On Nov 24, 2009, at 1:52 PM, Anil Kumar Veeramalli wrote:

> Hi,
>
> 1) bp.getParameterizedHeaders().getFirst("Content-
> Disposition").getParameters().get("name"), used to print the content
> of the file.
> 2) as per your new API, I used
> bp.getContentDisposition().getParameters().get("name"). is not
> showing the content of the file I uploaded.
>

Note that the "name" parameter is the name of the file and not the
contents of the file.

What is the value?

You should be able to use:

   bp.getContentDisposition().getName();

and it should have the same value as obtained from:

   bp.getContentDisposition().getParameters().get("name")

because the former is obtained from the latter:

     public FormDataContentDisposition(HttpHeaderReader reader) throws
ParseException {
         super(reader);
         if (!getType().equalsIgnoreCase("form-data")) {
             throw new IllegalArgumentException("The content
dispostion type is not equal to form-data");
         }

         name = getParameters().get("name");
         if (name == null) {
             throw new IllegalArgumentException("The name parameter is
not present");
         }
     }


BTW it is not necessary to manually call bp.cleanup, it will be
performed by Jersey if you utilize the injection mechanism for
obtaining body parts.

Paul.