Win a copy of Java Challengers this week in the Java in General forum!

Myat Thu

Greenhorn
+ Follow
since Dec 10, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Myat Thu

Hello All,

I want to write program which can retrieve information of Folders structures and Files.
Becaue i planted to make treeview folder and file structure.
I want folders information dynamically.
Here is my current coding, please take a look.

import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPListParseEngine;

public class FTPLocation {
public static void main(String args[]){
try{
FTPClient client=new FTPClient();

client.connect("localhost");
client.login("rootadmin","rootadmin");

FTPListParseEngine engine= client.initiateListParsing("Uploaded");
while(engine.hasNext()){
FTPFile[] filess=engine.getNext(30);
int count = filess.length;
while(count != 0){

if(filess[count-1].getRawListing().toString().startsWith("d")){
System.out.println("Folder Name:"+filess[count-1].getName());
/*******************************************************************************************/
/** HERE I WANT TO MAKE LOOPING TO GET INNER FOLDER AND FILES
/*******************************************************************************************/
}else{
System.out.println("File Name:"+filess[count-1].getName());
}
count = count - 1;
}
}
}catch(IOException e){
e.printStackTrace();
}
}
}


Here is my console output.

File Name:temp.xml
File Name:Min A Twet - Myo Kyawt Myaing.m4a
Folder Name:Old
Folder Name:New
Folder Name:InventoryEjb


Please suggest me how should i do.
12 years ago
Hi All,

How should i do to create javascript treeview
that display files and folders
from real location of client PC.
location like that (c:\java\....)
Please give me suggestion how should I do.
Please tell me which web link is good for me who face problem like that.

Let me know your suggestion please.
Hi All,

I want multiple files to upload to Web(or)FTP Server.
So, now what i have been done is
i carried whichever files and wherever location from client browser to servlet file.
Here is my servlet code.

My problem is i don't know how to write multiple file to server.
If i need to use BufferedWriter to write multiple file, how should i do.
I want to write not just single file, i need to write multiple files and mulitple files type.
Please give me suggestion.

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{

try{
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
InputStreamReader input = new InputStreamReader(request.getInputStream());
BufferedReader buffer = new BufferedReader(input);

String line ="";
do{
line = buffer.readLine();
System.out.println("Multipart data " + line );
}while(line != null);
}
}catch(Exception e){
e.printStackTrace();
}

}

Here is my console output.

10:03:29,390 INFO [STDOUT] Multipart data -----------------------------7d85d1d7027c
10:03:29,390 INFO [STDOUT] Multipart data Content-Disposition: form-data; name="txtFile1"; filename="D:\TestForUpload\Phrase1.txt"
10:03:29,390 INFO [STDOUT] Multipart data Content-Type: text/plain
10:03:29,390 INFO [STDOUT] Multipart data
10:03:29,390 INFO [STDOUT] Multipart data Form-based File upload in HTML is defined in RFC 1867.
10:03:29,390 INFO [STDOUT] Multipart data The enctype attribute of the form element in HTML specifies the content
10:03:29,390 INFO [STDOUT] Multipart data type of the data submitted to the server.
10:03:29,390 INFO [STDOUT] Multipart data The default encrypt type is application/x-www-form-urlencoded .
10:03:29,406 INFO [STDOUT] Multipart data This content type is not efficient for forms containing non-ASCII data,
10:03:29,406 INFO [STDOUT] Multipart data binary data or files. In such case, the encrypt type multipart/form-data is used.
10:03:29,406 INFO [STDOUT] Multipart data A typical HTML form for file upload looks like:
10:03:29,406 INFO [STDOUT] Multipart data -----------------------------7d85d1d7027c
10:03:29,406 INFO [STDOUT] Multipart data Content-Disposition: form-data; name="txtFile1"; filename="D:\TestForUpload\Phrase2.txt"
10:03:29,406 INFO [STDOUT] Multipart data Content-Type: text/plain
10:03:29,406 INFO [STDOUT] Multipart data
10:03:29,406 INFO [STDOUT] Multipart data Once the form is submitted, the binary multipart form-data is available in the HttpServletRequest
10:03:29,406 INFO [STDOUT] Multipart data as an InputStream. The regular form data are not available as Parameter and
10:03:29,406 INFO [STDOUT] Multipart data request.getParameter(?hsubmit?h) will always return null. So for any data submitted,
10:03:29,406 INFO [STDOUT] Multipart data you will have to know the content and then retrieve the content by parsing through the stream:
10:03:29,406 INFO [STDOUT] Multipart data -----------------------------7d85d1d7027c
10:03:29,406 INFO [STDOUT] Multipart data Content-Disposition: form-data; name="txtFile1"; filename="D:\TestForUpload\Phrase3.txt"
10:03:29,406 INFO [STDOUT] Multipart data Content-Type: text/plain
10:03:29,406 INFO [STDOUT] Multipart data
10:03:29,406 INFO [STDOUT] Multipart data You can write a parser yourself to analyze each multipart data from the stream and grab it
10:03:29,406 INFO [STDOUT] Multipart data as they apply to your application. There are some good ones already written.
10:03:29,406 INFO [STDOUT] Multipart data Apache has a Commons Fileupload Library, now let?fs see how we can use it to upload files.
10:03:29,406 INFO [STDOUT] Multipart data -----------------------------7d85d1d7027c
10:03:29,406 INFO [STDOUT] Multipart data Content-Disposition: form-data; name="txtFileOther"; filename=""
10:03:29,406 INFO [STDOUT] Multipart data Content-Type: application/octet-stream
10:03:29,406 INFO [STDOUT] Multipart data
10:03:29,406 INFO [STDOUT] Multipart data
10:03:29,406 INFO [STDOUT] Multipart data -----------------------------7d85d1d7027c--
10:03:29,406 INFO [STDOUT] Multipart data null
12 years ago
Hello Ulf Dittmer,

I am using apache ftp server, not tomcat ftp server sorry about that.
Yes, it doesn't matter if it cannot run in GUI mode.
I want to know more command line for FTP Server.
Now what make me very difficult is i don't know how to operate ftp server.
Here is my error list and files which i used.
Please tell me what i need to do.

User name = admin
Password = admin

It is this username and password which i want to use in order to login fpt server.
And then
If i want to use mysql db, how should i do.
I am using window xp sp2 and apache ftpserver-1.0.0-M3.
Please let me know what shoud i do.


C:\FTPServer\bin>service install ftpd C:\FTPServer\res\conf\ftpd-typical.xml
Installing the service 'ftpd' ...
Using FTPD_HOME: C:\FTPServer
Using JAVA_HOME: c:\Java\jdk1.6.0
Using JVM: c:\Java\jdk1.6.0\jre\bin\server\jvm.dll
start
start;C:\FTPServer\res\conf\ftpd-typical.xml
start;C:\FTPServer\res\conf\ftpd-typical.xml
The service 'ftpd' has been installed.

C:\FTPServer\bin>net start ftpd
The Apache FtpServer ftpd service is starting.
The Apache FtpServer ftpd service was started successfully.


C:\FTPServer\bin>ftp pc69
> ftp: connect :Unknown error number
ftp> ls
Not connected.
ftp>

Here is ftpd-typical.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version
2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the
License.
-->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
"
id="myServer">
<listeners>
<nio-listener name="default" port="2121">
<ssl>
<keystore file="./res/ftpserver.jks" password="password" />
</ssl>
</nio-listener>
</listeners>
<file-user-manager file="./res/conf/users.properties" />
</server>


Here is users.properties file.

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Password is "admin"
ftpserver.user.admin.userpassword=21232F297A57A5A743894A0E4A801FC3
ftpserver.user.admin.homedirectory=./res/home
ftpserver.user.admin.enableflag=true
ftpserver.user.admin.writepermission=true
ftpserver.user.admin.maxloginnumber=0
ftpserver.user.admin.maxloginperip=0
ftpserver.user.admin.idletime=0
ftpserver.user.admin.uploadrate=0
ftpserver.user.admin.downloadrate=0

ftpserver.user.anonymous.userpassword=
ftpserver.user.anonymous.homedirectory=./res/home
ftpserver.user.anonymous.enableflag=true
ftpserver.user.anonymous.writepermission=false
ftpserver.user.anonymous.maxloginnumber=20
ftpserver.user.anonymous.maxloginperip=2
ftpserver.user.anonymous.idletime=300
ftpserver.user.anonymous.uploadrate=4800
ftpserver.user.anonymous.downloadrate=4800
Hi all,

I started Apache FTP Server 1.0.0 M3.
My FTP service is start.
But i don't know what is valid username and password.
I get error 503 Authentication failed in command prompt.
I am using window xp sp 2.
Please guide me which file is use in order to define username and passord.
And then how can i write valid syntax for username and password file.
Please guide me.
Thank you for your reply,

I see http://commons.apache.org/net/ which you tell.
It is good link.
But, now what my problem is i want to create Tomcat FTP Server.
I have tomcat ftpserver-1.0.0-M3.zip file.
I check documentation which is under this folder.
But i did not find ftpd_ui.bat file. (I am using window)
So how can i configure apache ftp server using Swing UI?
I want to configure apace ftp server using Swing UI.
Please guide me again.
Hi all,

I am new to Java FTP Field.
I want to create Multiple file uploading program
using java ftp service and J2EE.
Therefore, Please guide me
which links is suitable to see and learn,
which e book is should read,
which web link is good reference and so on.