Sohaila Roberts wrote:
>
> Hi, I know there is an example of uploading files via servlets in the
> o'reilly servlet programming book, I was just wondering what would happen
> if i had the following html page
>
>
Read about "Java Activation Framework", and "Java Mail", from Sun,
there are the resources for your problem.

One way that works for me its:

  protected void doPost( HttpServletRequest req, HttpServletResponse res
) {
    ServletDataSource f = new ServletDataSource(req);
    DataHandler dh = new DataHandler( f );
    try {
      Object m_o = dh.getContent();
      MimeMultipart m = (MimeMultipart)( m_o );
      for (int i = 0 ; i < m.getCount() ;  i++ ) {
        MimeBodyPart mbp = (MimeBodyPart)m.getBodyPart(i);
        Object obj = mbp.getContent();
...

Im trying to generate a DataContentHandler, that regconizes
"multipart/form-data"
(rfc1867) instead to been reconized as "MimeMultipart", but I have
promblems
with mailcap and mime.types, etc.
When I finish it, I will post here, because its a "common problem" for a
lot
of people.

And you also need:

public class ServletDataSource implements javax.activation.DataSource {

  javax.servlet.http.HttpServletRequest httpReq;

  public ServletDataSource( javax.servlet.http.HttpServletRequest req )
{
    httpReq = req;
  }

  public java.lang.String getContentType() {
    return httpReq.getContentType();
  }

  public java.io.InputStream getInputStream() throws java.io.IOException
{
    return httpReq.getInputStream();
  }

  public java.lang.String getName() {
    return "ServletDataSource";
  }

  public java.io.OutputStream getOutputStream() throws
java.io.IOException {
    throw new java.io.IOException("Solo stream de entrada");
  }
}

Damien Serra

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to