Okay this is exactly what I am looking at doing. We need to do a directory
listing off the IFS on a AS400. I have found a applet that works perfectly
for it. But now I need to convert it to a servlet so it can display a
webpage.

I know what to do for a "hello world" servlet with passing a parm, but now I
need help converting this program:

import java.io.*;
import java.util.*;
import com.ibm.as400.access.*;

public class IFSList extends Object
{
    public static void main(String[] parameters) {
        System.out.println( " " );

        String dir           = "root";
        String system        = "systemIP";
        String user          = "user";
        String password      = "pass";

        // if both parameters were not specified, display help text and
exit.
        if (parameters.length >= 1) {

            // Assume the first parameter is the system name and
            // the second parameter is the directory name
            String directoryName = dir + parameters[0];

            try {
                // Create an AS400 object for the AS/400 system that holds
the files.
                AS400 as400 = new AS400(system, user, password);

                // Create the IFSFile object for the directory.
                IFSFile directory = new IFSFile(as400, directoryName);

                // Generate the list of name.  Pass the list method the
                // directory filter object and the search match criteria.
                //
                // Note - this example does the processing in the filter
                // object.  An alternative is to process the list after
                // it is returned from the list method call.
                String[] directoryNames = directory.list(new
directoryFilter(),"*");



                // Tell the user if the directory doesn't exist or is empty
                if (directoryNames == null)
                    System.out.println("The directory does not exist");
                else if (directoryNames.length == 0)
                    System.out.println("The directory is empty");
            }
            catch (Exception e) {
            // If any of the above operations failed say the list failed
            // and output the exception.
                System.out.println("List failed");
                System.out.println(e);
            }
        }
    }
}

class directoryFilter implements IFSFileFilter {
    public boolean accept(IFSFile file) {
        try {
            if (!file.isDirectory()) {
                System.out.print(file.getName());
                System.out.println("/t");
                System.out.println(file.length());
            }
            return true;
        }
        catch (Exception e) {
            return false;
        }
    }
}

My major problems are "public class IFSList extends Object" and the
directoryFilter class. How do I convert these parts over? Just some hand
holding is all I need here.

Mike Wills
AS400 Programmer
[EMAIL PROTECTED]

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to