FileDocCategorySizeDatePackage
MovieClient.javaAPI DocExample2266Sun Jul 07 09:44:48 BST 2002javajaxb

MovieClient

public class MovieClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        if (args.length != 1) {
            System.out.println("Usage: java javajaxb.MovieClient " +
                "[XML configuration file]");
            return;
        }

        try {
            File configFile = new File(args[0]);
            FileInputStream inputStream = 
                new FileInputStream(configFile);

            // Unmarshal the connection information
            Connection connection = Connection.unmarshal(inputStream);

            // Determine the data needed
            Host host = connection.getHost();
            Url configURL = connection.getUrl();
            String filename = new StringBuffer("/")
                .append(configURL.getContext())
                .append("/")
                .append(configURL.getServletPrefix())
                .append("/")
                .append(configURL.getServletName())
                .toString();

            // Connect to the servlet
            URL url = new URL("http", 
                              host.getHostname(),
                              Integer.parseInt(host.getPort()),
                              filename);
            HttpMessage msg = new HttpMessage(url);

            // Indicate we want a listing
            Properties props = new Properties();
            props.put("action", "list");

            // Get response
            InputStream in = msg.sendPostMessage(props);
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(in));

            // Output response to screen
            String line = null;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }