Using javax.activation.MimeType to Parse RFC2045/2046 multipart/form-data (JavaMail, J2EE)
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Chuong_Pham
Posted On:   Monday, November 18, 2002 05:02 PM

Hi, I am working on a web base File Uploading utility. I got the whole thing working by writing my own Parser Bean class to parse the mulitpart/form-data (in the RFC2045/2046 format). It was a great learning curve I must say. Now I have a problem, the parser I've written I think lacks performance. I don't have much time to invest in researching/developing top parsing algorithms, so now I'm looking at the javax.activation.MimeType class for answers. I have implemeted the MimeType class with some Exception "Unable to find a sub type". My code as follows: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {    More>>

Hi,


I am working on a web base File Uploading utility.
I got the whole thing working by writing my own Parser Bean class to parse the mulitpart/form-data (in the RFC2045/2046 format). It was a great learning curve I must say.
Now I have a problem, the parser I've written I think lacks performance. I don't have much time to invest in researching/developing top parsing algorithms, so now I'm looking at the javax.activation.MimeType class for answers.
I have implemeted the MimeType class with some Exception "Unable to find a sub type".


My code as follows:

			

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
MimeType myObj;

try
{
myObj = new MimeType(request.getInputStream().toString());

MimeTypeParameterList mList = mObj.getParameters();
Enumeration eList = mList.getNames();
while (eList.hasMoreElements())
{
System.out.println(">>> " + eList.nextElement());
System.out.println("=== " + mList.get((String)eList.nextElement()));
}
System.out.println("Base Type : " + mObj.getBaseType());
System.out.println("Prim Type : " + mObj.getPrimaryType());
System.out.println("Sub Type : " + mObj.getSubType());
} catch (MimeTypeParseException mtpe)
{
System.out.println("FILE UPLOAD ERROR!");
System.out.println(mtpe.getMessage());
}
}


So, I must have done something wrong, please advise me.


Thanks.

   <<Less

Re: Using javax.activation.MimeType to Parse RFC2045/2046 multipart/form-data (JavaMail, J2EE)

Posted By:   John_Zukowski  
Posted On:   Wednesday, November 20, 2002 10:32 PM

If you don't have the time, there are implementations of this already done you can find on the web with a simple Google search.
About | Sitemap | Contact