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