users@glassfish.java.net

Re: (JAX-RS) How to correctly recieve multipart message using _at_Post ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 26 Nov 2008 10:22:34 +0100

On Nov 25, 2008, at 6:28 PM, glassfish_at_javadesktop.org wrote:

> Thank you for your reply.
>
> Sadly, it doesn't work with @FormParam("part1") String p1 ...
> I tried before, the result is: both strings are null.
> Apache is sending: multipart/form-data; boundary=Tl14abid [...]
>
> I have no java mail lib and I don't want additional dependency in my
> project just to be able to read multipart data. Is there really no
> other way?

Unfortunately not. What are your objections to the additional
dependency on JavaMail?

The only way you will get support for processing multipart messages is
if you add the JavaMail jar file to the classpath of your web app [1].
If you are using an app server like GF then it will already be included.

The alternative is to not use multipart/* at all and instead use
"application/x-www-urlencoded" which is supported without any
additional dependencies. This approach is very useful when you are
sending small character-based content. If you want to send larger
character-based content or binary content then multipart/* is
recommended.

Paul.

[1] https://jersey.dev.java.net/source/browse/*checkout*/jersey/trunk/jersey/dependencies.html