JavaServer Pages (JSP) and JSTL - Commons error
I tried uploading file using apache commons HttpClient-based file upload using the code given below.
But it works perfectly in my system and when i try the same in my friend's system i get the output as
exception in sendfile..org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 8000 ms
this is the code forSender.jsp
<%
try{
sendFile(ip,f);
}
catch(Exception e)
{
out.println("<br>exception in sendfile..");
out.println("<br>"+e.toString());
}
%>
<%!privatevoid sendFile(String ip, File f)throws HttpException,FileNotFoundException,IOException
{
String url ="http://" +ip+":8080//gops6//Receiver.jsp";
HttpClient client =new HttpClient();
MultipartPostMethod mPost =new MultipartPostMethod(url);
client.setConnectionTimeout(8000);
mPost.addParameter(f.getName(), f);
int statusCode1 = client.executeMethod(mPost);
//out.println("statusLine>>>" + mPost.getStatusLine());
mPost.releaseConnection();
}
%>
this is the code forReceiver.jsp
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="org.apache.commons.httpclient.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.*"%>
<%
DiskFileUpload fu =new DiskFileUpload();
fu.setSizeMax(1000000);
List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();
while(itr.hasNext())
{
FileItem fi = (FileItem)itr.next();
if(!fi.isFormField())
{
File f=new File(fi.getName());
File fNew=new File("C:\\Files<br clear="all" />"+f.getName());
fi.write(fNew);
}
}
i tried changing the connection timeout to big values.. still the problem exists but only in my friends pc..
please help..

