Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Query on Uploading of file


Message #1 by bikashpaul_2001@y... on Sat, 24 Nov 2001 06:29:16
Hi,

I have one swing interface by this Interafce I can upload my file(Of any 
extension) in my "Network Neighbourhood". through my servlet programme(Iam 
using jspsmatupload's smartupload class for uploading).I connect my 
Interface with my servlet through "URLConnection"Now My problem is that I 
can upload file size upto 4MB and I can't upload my file in virtual path
(i.e. on Internet).My programme working perfectly in my Networked places 
in shareable directory(with m/c IP address also). But not in password 
protected directory.Can any one plz tell  me is there any method for 
entering in password protected directory by mentioing password in my 
servlet programme.How I can upload file on Internet(that means on virtual 
IP address).And how I can increase the uploading capacity of size of file.
PLEASE HELP ME.(Iam sending destination path from my swing Interface to 
servlet)

Below r my codes:-
-----------------

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.jspsmart.upload.*;

public class servletUpload extends HttpServlet {
	
	private ServletConfig config;
	
	final public void init(ServletConfig config) throws 
ServletException {
		this.config = config;
	}
	
	final public ServletConfig getServletConfig() {
		return config;
	}
	
	public void doGet(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {

		PrintWriter out = response.getWriter();
		
	}
	
	
	protected void doPost(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {
		
		PrintWriter out = response.getWriter();		
		String path=request.getParameter("x");
		out.println("\n"+"Destination URL:"+""+path);
		int count=0;
		SmartUpload mySmartUpload = new SmartUpload();
		com.jspsmart.upload.Files myFiles = mySmartUpload.getFiles
();

		try {
			
			mySmartUpload.initialize(config,request,response);
			
			mySmartUpload.upload();
			count = mySmartUpload.save
(path,mySmartUpload.SAVE_AUTO);	

//I also tried with this[count = mySmartUpload.save
(path,mySmartUpload.SAVE_VIRTUAL);]AND	
//count = mySmartUpload.save(mySmartUpload.getRequest().getParameter
(path));
		
			out.println(count + " file uploaded.");
			out.println("File size =" + mySmartUpload.getSize
() + "bytes");			
		} catch (Exception e){			
			out.println("Unable to upload the file.<br>");
			out.println("Error:"+e.toString());
		}
		
		
          }
	
	public void  destroy () {
	}

} 
Thanks for ur valuable time
Bikash

  Return to Index