Java 从http客户端获取404

Java 从http客户端获取404,java,httpclient,Java,Httpclient,在这里,我使用HTTP-CLIENT调用servlet,但如果我只单击“HTTP://:8080/RemediPRMS/WritePingData”这个链接,它会给我响应代码200,但如果我从applet运行它,它会给我404 Deployment descriptor mapping is : <servlet> <servlet-name>WritePingData</servlet-name> <s

在这里,我使用HTTP-CLIENT调用servlet,但如果我只单击“HTTP://:8080/RemediPRMS/WritePingData”这个链接,它会给我响应代码200,但如果我从applet运行它,它会给我404

    Deployment descriptor mapping is :
     <servlet>
        <servlet-name>WritePingData</servlet-name>
        <servlet-class>com.clientToServer.FileUploader.WritePingData</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>WritePingData</servlet-name>
        <url-pattern>/WritePingData</url-pattern>
      </servlet-mapping>

    try{
                System.out.println("folder.listFiles().length"+folder.listFiles().length);
                if(folder.listFiles().length > 0){
                    System.out.println("inside if file found[][][[[][][][][][][");
                    String remediEndpoint = "http://<endpoint>:8080/RemediPRMS/WritePingData";
                    FileInputStream fis = null;
                    System.out.println("above for loop");
                    File arr[] =folder.listFiles();//file array
                    System.out.println("array pass");

                        PostMethod post = null;
                        System.out.println("just above for loop");
                        for(int i=0;i<arr.length;i++){
                            try{
                                System.out.println("inside for loop");
                                File targetFile = new File(path+"\\"+arr[i].getName());
                                fis = new FileInputStream(targetFile);
                                post = new PostMethod(remediEndpoint);
                                post.setRequestEntity(new InputStreamRequestEntity(fis, targetFile.length()));
                                post.setRequestHeader("Content-type","text/plain; UTF-8"); 
                                HttpClient httpclient = new HttpClient();
                                httpclient.setConnectionTimeout(10000);
                                int status = httpclient.executeMethod(post);
                                fis.close();
                                //boolean deletestatus= targetFile.delete();
                                System.out.println("status from server : "+status);
                            }catch(Exception e){
                                LOGGER.info("Exception in file upload (http client): "+e);
                            }
                        }
                        post.releaseConnection();
                    }else{
                        LOGGER.info("THERE IS NO MORE FILE TO UPLOAD ");
                    }
                }catch(Exception e){
                    LOGGER.info("No directory inside LogData: "+e);
                }
部署描述符映射为:
写字板
com.clientToServer.FileUploader.WritePingData
写字板
/写字板
试一试{
System.out.println(“folder.listFiles().length”+folder.listFiles().length);
如果(folder.listFiles().length>0){
System.out.println(“找到内部if文件[][[[]);
String remedindpoint=“http://:8080/RemediPRMS/WritePingData”;
FileInputStream fis=null;
System.out.println(“以上为循环”);
文件arr[]=folder.listFiles();//文件数组
System.out.println(“数组传递”);
PostMethod post=null;
System.out.println(“循环的正上方”);

对于(inti=0;i您需要输入主机名作为url的一部分

e、 g

或者假设您是,仍然处于沙盒状态的小程序无法运行

他们无法连接到任何第三方服务器(源服务器以外的任何服务器)或从中检索资源


请参见

Ya我使用相同的myserver意味着我在那里添加了ip地址
http://myserver:8080/RemediPRMS/WritePingData