HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:441)
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
org.apache.commons.net.ftp.FTP.user(FTP.java:670)
org.apache.commons.net.ftp.FTPClient.login(FTPClient.java:637)
org.apache.jsp.ftpUploadTest_jsp.UploadFile(ftpUploadTest_jsp.java:44)
org.apache.jsp.ftpUploadTest_jsp._jspService(ftpUploadTest_jsp.java:153)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
--------------------------------------------------------------------------------

解决方案 »

  1.   

    忘了告诉大家,我的运行环境是:eclipse3.1+tomcat5.0+jdk1.42,请高手及时出现吧.现身吧
      

  2.   

    下面这句不能这样写,要单独定义server和port
     private String server = "192.9.100.88:2121";改成这样:private String server = "192.9.100.88";
             int port = "2121";
    另外你调用方法传递的值错了public class Upload
    {
    private String server = "192.9.100.88";//先在自己的机上设一个FTP站点吧 private String username = "username";//登录名 private String password = "password";//密码 private String local = "E:\\ww.txt";//FTP站点目录 private String remote = "E:\\ftp";//要传的文件.  // 不使用默认的端口
    private int port = 2121; public int getPort()
    {
    return port;
    } public void setPort(int port)
    {
    this.port = port;
    } public String getLocal()
    {
    return local;
    } public void setLocal(String local)
    {
    this.local = local;
    } public String getPassword()
    {
    return password;
    } public void setPassword(String password)
    {
    this.password = password;
    } public String getRemote()
    {
    return remote;
    } public void setRemote(String remote)
    {
    this.remote = remote;
    } public String getServer()
    {
    return server;
    } public void setServer(String server)
    {
    this.server = server;
    } public String getUsername()
    {
    return username;
    } public void setUsername(String username)
    {
    this.username = username;
    } public boolean UploadFile(String server, String username, String password,
    String local, String remote ,int port)
    { FTPClient ftp = new FTPClient();
    int reply;
    try
    {
    ftp.connect(server,port);
    reply = ftp.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply))
    {
    ftp.disconnect();
    return false;
    }
    } catch (IOException e)
    {
    if (ftp.isConnected())
    {
    try
    {
    ftp.disconnect();
    } catch (IOException f)
    {
    return false;
    }
    }
    } try
    {
    if (!ftp.login(username, password))
    {
    ftp.logout();
    return false;
    }
    ftp.setFileType(FTP.BINARY_FILE_TYPE);
    ftp.enterLocalPassiveMode();
    //这个地方暂不做修改
    String[] dirArray = remote.split("/");
    if (dirArray.length > 1)
    {
    for (int i = 0; i < dirArray.length - 1; i++)
    {
    if (dirArray[i] != null && dirArray[i] != null)
    if (!ftp.changeWorkingDirectory(dirArray[i]))
    {
    ftp.makeDirectory(dirArray[i]);
    ftp.changeWorkingDirectory(dirArray[i]);
    }
    }
    }
    File file = new File(local);
    if(!file.exists()||!file.canRead()||file.isDirectory()){
    return false;
    }
    InputStream input = new FileInputStream(file);
    ftp.storeFile(file.getName(), input);
    input.close();
    ftp.logout();
    } catch (FTPConnectionClosedException e)
    {
    return false;
    } catch (IOException e)
    {
    return false;
    } finally
    {
    if (ftp.isConnected())
    {
    try
    {
    ftp.disconnect();
    } catch (IOException f)
    {
    return false;
    }
    }
    }
    return true;
    } public static void main(String args[])
    {
    Upload ud = new Upload();
    ud.UploadFile(ud.getServer(), ud.getUsername(),  ud
    .getPassword(), ud.getLocal(), ud.getRemote(),ud.getPort());
    }}这样试试