CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.

YesSoftware Forums -> CodeCharge Studio -> Java

 Please any one help me to upload from client using jsp..

Print topic Send  topic

Author Message

Posts: 4
Posted: 08/18/2007, 1:57 AM

hi. All

i am using j2EE server 1.4 for my intranet project. i want upload file and download file from client machine to server(Linex file system.). also better if possible download from linux server to client machine.. i want to know wheter it is possible in java or needs some other dll like ChilKat.dll to upload and download client.. please reply me as soon as possible..

View profile  Send private message

Posts: 4
Posted: 08/18/2007, 2:46 AM

View profile  Send private message

Posts: 31
Posted: 08/20/2007, 2:34 AM

You can upload and download files without any dll or other.
Just use CCS Upload component.

And if you have any wxpirience with java you can create own servlets for upload or download if you need something special.
View profile  Send private message

Posts: 4
Posted: 08/20/2007, 3:37 AM


i have tried this code..

<!-- upload.jsp -->

<%@ page import="*" %>

<%String contentType = request.getContentType();

String file = "";

String saveFile = "";

FileOutputStream fileOut = null;

if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0))


DataInputStream in = new DataInputStream(request.getInputStream());

int formDataLength = request.getContentLength();

byte dataBytes[] = new byte[formDataLength];

int byteRead = 0;

int totalBytesRead = 0;

while (totalBytesRead < formDataLength)


byteRead =, totalBytesRead, formDataLength);

totalBytesRead += byteRead;


try {

file = new String(dataBytes);

saveFile = file.substring(file.indexOf("filename=\"") + 10);

saveFile = saveFile.substring(0, saveFile.indexOf("\n"));

saveFile = saveFile.substring(saveFile.lastIndexOf("/") + 1,saveFile.indexOf("\""));

int lastIndex = contentType.lastIndexOf("=");

String boundary = contentType.substring(lastIndex + 1,contentType.length());

int pos;

pos = file.indexOf("filename=/" + 1);

pos = file.indexOf("\n", pos) + 1;

pos = file.indexOf("\n", pos) + 1;

pos = file.indexOf("\n", pos) + 1;

int boundaryLocation = file.indexOf(boundary, pos) - 4;

int startPos = ((file.substring(0, pos)).getBytes()).length;

int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;

String folder = "/tmp/";

fileOut = new FileOutputStream(folder + saveFile);


fileOut.write(dataBytes, startPos, (endPos - startPos));
out.println("FileUploaded Succefully");

fileOut.flush(); } catch(Exception e) { out.print(e);

} finally

{ try


}catch(Exception err)





its not working fine.. its only for upload in linux server.. its transfered successfully.. but its open fine when text file open. but word fine and audio fine. not opened clearly.. it contains some ascii values. i want to open clearly.. please help me.

Thanks and regards.
Senthil ..

View profile  Send private message

Posts: 31
Posted: 08/20/2007, 5:04 AM

1. Upload nad download it's 2 different processes.
2. For upload some file you don't need any custom or written manually code. Just use fileUpload component.
3. For donload from server you should adjust tomcat for this or use servlet which return file.

View profile  Send private message

Posts: 4
Posted: 08/20/2007, 5:38 AM


please give some idea regarding CSS. what is that.. how can i use. still i did't use css..
give me some sample program. and how can i import in jsp page..


View profile  Send private message
Posted: 08/20/2007, 6:08 AM

Not CSS but CCS.
If you are not a CCS user, I suggest posting your Java questions
on one of the many Java forums.
This is a forum for CCS CodeCharge Studio Users using the Java flavour.


Posts: 5
Posted: 12/28/2007, 10:19 AM

The above file upload can be also done as

// Hi Fnds,
//This is the Simple Code that works well to upload any File Checkout

//Html Code for Browsing Purpose
<form action="NewUpload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<td align="left"><b>Select a file to upload :</b></td>
<td align="left">
<input type="file" name="filename" size="50">
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">

// this is the JSP Code//

<%@ page import="java.util.*,*"%>

String path=request.getParameter("filename");
String newPath="";
int count=0;

ArrayList arr=new ArrayList();
StringTokenizer st=new StringTokenizer(path,"\\");
// create ur own path

int c;
FileInputStream fis=new FileInputStream(path);
FileOutputStream fos=new FileOutputStream(newPath);

out.println("Thanks for using");
out.println("1.File1 Uploaded from :: "+path);
out.println("2.Uploaded File1 is Saved in :: "+newPath);


Arise, Awake and Stop not till your goal is reached
View profile  Send private message

Posts: 2
Posted: 03/12/2008, 1:06 PM

You could try JSP Upload script sample at:

If HTML form upload doesn't fit to your need then you could try an upload applet named JFileUpload. It could also work with the same JSP upload script:

I hope it helps.
View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.