0
這裏我使用HTTP-CLIENT來調用servlet,但是如果我只點擊「http://:8080/RemediPRMS/WritePingData」這個鏈接,它會給我響應代碼200,但是如果我運行它小程序它給了我404從http客戶端獲取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);
}
雅我用同樣的手段MYSERVER我添加的IP地址有 – user2826111
編輯答案是由於新信息 –