0

Possible Duplicate:
Convenient way to parse incoming multipart/form-data parameters in a Servlet

Is there any convenient way to read and parse data from incoming post request.

I get the Mime multipart Http POST message like this:

InputStream  client = request.getInputStream();
        PrintWriter pw = response.getWriter();
        //pw.write("Test Recuperation InputStream");

        BufferedReader br = new BufferedReader(new InputStreamReader(client)); 
        StringBuffer chaine= new StringBuffer();
        String ligne;

          while((ligne=br.readLine())!=null) { 
              chaine.append(ligne);
          }
          client.close();

and i receive the content like this:

Content-Disposition: form-data; name="account_did"
9384602893
--------------------------------f57395a75e4f
Content-Disposition: form-data; name="service_type"
s2t

How canI parse the content(the value of name= and the text below) with JavaMail (The Method getDisposition return me only "form-data")?

Thx a lot for your help

Community
  • 1
  • 1
user799698
  • 39
  • 4
  • 11

1 Answers1

0

First, reading a mime message from a servlet can be done using the standard HttpServletResponse methods getParameter("abc"). However to get the raw message, do as you have done and access the request body via the InputStream.

In JavaMail, the constructor to javax.mail.internet.MimeMessage contains a parameter for a mime-encoded InputStream. That should be able to parse the message for you.

kwo
  • 1,834
  • 1
  • 15
  • 9