Hi, Dear all ...I need some helps ~~~
I am coding a servlet about file upload...
I use oreilly's package , name MultiRequest , to help to handle
multipart/form-data reequests.
But I meet a problem ....
My OS is win 2000 and Tomcat 3.2.1 & Jdk 1.3.0_01
When I startup server , in the webpage , this servlet only can work
ONCE.....
I don't know what' wrong with this situation ...
Where I miss something ???
Or there is something need to rewrtie in server.xml or web.xml ???

Thanks ...

Sincerely,
 Jessie

PS: This is my first time to wrtie Servlet and Tomcat ....

Here is code context ~~~

import javax.servlet.*;
import javax.servlet.http.*;
file://import javax.servlet.jsp.*;
file://import javax.servlet.jsp.tagext.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Vector;
file://import java.beans.*;
import java.io.*;
import java.util.*;
import com.oreilly.servlet.MultipartRequest;


public class fUpload extends HttpServlet {

    String saveDirectory = "C:\\Upload\\"; file://宣� 將� 
傳的檔案放置到伺服
器的C:\Upload目錄中
    int    maxPostSize = 5 * 1024 * 1024 ;   file://宣� 限制� 
傳之檔案大小為
5MB
    String FileDescription[] = {null,null,null}; file://宣� 敘述� 傳檔案內容
的� 數,型態是String
    String FileName = null; file://宣� � 傳檔案名稱
    int count = 0 ; file://計算� 傳檔案之個數


    public void service(HttpServletRequest req,HttpServletResponse resp)
        throws ServletException,java.io.IOException{
     doPost(req,resp);
    }


    public void doPost(HttpServletRequest request, HttpServletResponse
response)
        throws IOException, ServletException {

        PrintWriter out = null;
        MultipartRequest multi = new MultipartRequest(request ,
saveDirectory , maxPostSize );

        try {

            response.setContentType("text/html;charset=big5");

            out = response.getWriter();


                out.println("\r\n");

                out.println("\r\n");

                out.println("\r\n");

                out.println("\r\n\r\n");

                out.println("\r\n<html>\r\n<head>\r\n\t<title>File Upload
Test Page</title>\r\n</head>\r\n");

                out.println("\r\n<body>\r\n");


                 if ( multi.getParameter("File1") != null )


                  FileDescription[0] = multi.getParameter("File1");
                 }
                 else
                 { FileDescription[0] = "1"; }

                 if ( multi.getParameter("File2") != null )


                  FileDescription[1] = multi.getParameter("File2");
                 }
                 else
                 { FileDescription[1] = "2"; }

                 if ( multi.getParameter("File3") != null )


                  FileDescription[2] = multi.getParameter("File3"); }
                 else
                 { FileDescription[2] = "3"; }


                 Enumeration filesname = multi.getFileNames();

                 while (filesname.hasMoreElements())
                      {
                     String name = (String)filesname.nextElement();
                     FileName    = multi.getFilesystemName(name);
                     File f      = multi.getFile(name);
                     String ContentType = multi.getContentType(name);

                        if (FileName != null)
                     {
                       count ++;

                out.println("\r\n\t\t\t\t<font color=\"red\">� � 傳的第");

                out.print( count );
                out.println("個的檔案:</font><br>\r\n\t\t\t\t檔案名稱為:");

                out.print( FileName );
                out.println("<br>\r\n\t\t\t\t檔案型態為:");

                out.print( ContentType );
                out.println("<br>\r\n\t\t\t\t檔案的敘述:");

                out.print( FileDescription[count-1] );
                out.println("<br><br>\r\n");


                     }
                   }

                out.println("\r\n\t\t您總共� 傳<font color=\"red\">");

                out.print( count );
                out.println("</font>個檔案\r\n</body>\r\n</html>\r\n");


        } catch (Exception ex) {
          System.out.println(ex);
        } finally {
            out.flush();
            out.close();

        }
    }// end of doPost()

}

___________________________________________________________________________
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