166 lines
6.2 KiB
HTML
166 lines
6.2 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Example: Creating a traversable integrated file system tree(File three of three)" />
|
|
<meta name="abstract" content="" />
|
|
<meta name="description" content="" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="treelistjava" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Example: Creating a traversable integrated file system tree(File three
|
|
of three)</title>
|
|
</head>
|
|
<body id="treelistjava"><a name="treelistjava"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Creating a traversable integrated file system tree(File three
|
|
of three)</h1>
|
|
<div><p></p>
|
|
<div class="section"><p>This example code, in conjunction with the code in the other two
|
|
example files, displays an HTMLTree and FileListElement in a servlet. The
|
|
three files in the example are:</p>
|
|
</div>
|
|
<div class="section"><ul><li><a href="filetreeexamplejava.htm#filetreeexamplejava">FileTreeExample.java</a> -
|
|
generates the HTML frames and starts the servlet</li>
|
|
<li><a href="treenavjava.htm#treenavjava">TreeNav.java</a> - builds
|
|
and manages the tree</li>
|
|
<li>TreeList.java - this file, which displays the contents of selections made
|
|
in the TreeNav.java class</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm#codedisclaimer">Code
|
|
example disclaimer</a> for important legal information.</div>
|
|
</div>
|
|
<div class="section"><div class="p"><pre>////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// This source is an example of using the IBM Toolbox for Java HTML
|
|
// package classes, which allow you to easily build HTML and File Lists.
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
import java.io.PrintWriter;
|
|
import java.io.IOException;
|
|
import java.io.File;
|
|
|
|
import com.ibm.as400.access.AS400;
|
|
import com.ibm.as400.access.Trace;
|
|
import com.ibm.as400.access.IFSJavaFile;
|
|
import com.ibm.as400.util.html.HTMLMeta;
|
|
import com.ibm.as400.util.html.HTMLHeading;
|
|
import com.ibm.as400.util.html.HTMLConstants;
|
|
import com.ibm.as400.util.html.FileListElement;
|
|
import com.ibm.as400.util.html.*;
|
|
|
|
import javax.servlet.*;
|
|
import javax.servlet.http.*;
|
|
|
|
/**
|
|
* An example of using the FileListElement class in a servlet.
|
|
**/
|
|
public class TreeList extends HttpServlet
|
|
{
|
|
|
|
private AS400 sys_;
|
|
|
|
/**
|
|
* Process the GET request.
|
|
* @param req The request.
|
|
* @param res The response.
|
|
**/
|
|
public void doGet(HttpServletRequest req, HttpServletResponse resp)
|
|
throws ServletException, IOException
|
|
{
|
|
resp.setContentType("text/html");
|
|
|
|
try
|
|
{
|
|
|
|
PrintWriter out = resp.getWriter();
|
|
out.println("<html>\n");
|
|
out.println(new HTMLMeta("Expires",
|
|
"Mon, 02 Jan 1990 13:00:00 GMT"));
|
|
out.println("<body>\n");
|
|
|
|
// If the path parameter is not null, then the user has selected an
|
|
// element from the FileTreeElement list in the navigation frame.
|
|
if (req.getPathInfo() != null)
|
|
{
|
|
// Create a FileListElement passing in an AS400 system object and
|
|
// the Http servlet request. The request will contain the necessary
|
|
// path information to list out the contents of the FileTreeElement
|
|
// (directory) selected.
|
|
FileListElement fileList = new FileListElement(sys_, req);
|
|
|
|
// Alternately, create a FileListElement from a NetServer share name
|
|
// and share path.
|
|
// FileListElement fileList =
|
|
new FileListElement(sys_, req, "TreeShare",
|
|
"/QIBM/ProdData/HTTP/Public/jt400");
|
|
|
|
|
|
// Display the FileListElement contents.
|
|
out.println(fileList.list());
|
|
}
|
|
// Display this HTMLHeading if no FileTreeElement has been selected.
|
|
else
|
|
{
|
|
HTMLHeading heading = new
|
|
HTMLHeading(1,"An HTML File List Example");
|
|
heading.setAlign(HTMLConstants.CENTER);
|
|
|
|
out.println(heading.getTag());
|
|
}
|
|
|
|
out.println("</body>\n");
|
|
out.println("</html>\n");
|
|
out.close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Process the POST request.
|
|
* @param req The request.
|
|
* @param res The response.
|
|
**/
|
|
public void doPost (HttpServletRequest req, HttpServletResponse res)
|
|
throws ServletException, IOException
|
|
{
|
|
res.setContentType("text/html");
|
|
ServletOutputStream out = res.getOutputStream();
|
|
|
|
}
|
|
|
|
public void init(ServletConfig config)
|
|
throws ServletException
|
|
{
|
|
super.init(config);
|
|
|
|
// Create an AS400 object.
|
|
sys_ = new AS400("mySystem", "myUID", "myPWD");
|
|
}
|
|
}</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |