HTML + Java (Frontend/Backend Structure) This code provides the basic structure of an AS/400 application with Java as the back-end for connecting and interacting with the AS/400 system.

1. HTML Frontend (User Interface)


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AS/400 Application</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
        }
        header {
            background-color: #4CAF50;
            padding: 20px;
            text-align: center;
            color: white;
        }
        main {
            margin: 20px;
        }
        .card {
            background-color: white;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin: 10px 0;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px;
            font-size: 16px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            padding: 10px;
            text-align: left;
            border: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
        }
    <style>
</head>
<body>

<header>
    <h1>AS/400 Application Interface</h1>
    <p>Interact with your IBM iSeries (AS/400) system.</p>
</header>

<main>
    <div class="card">
        <h2>Authenticate</h2>
        <form id="authForm">
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
            <br><br>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
            <br><br>
            <button type="submit">Login</button>
        </form>
    </div>

    <div class="card">
        <h2>Database Operations</h2>
        <button onclick="fetchData()">Fetch Data</button>
        <button onclick="updateData()">Update Data</button>
        <table id="dataTable">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Name</th>
                    <th>Details</th>
                </tr>
            </thead>
            <tbody>
                <!-- Data rows will be inserted here by JavaScript -->
            </tbody>
        </table>
    </div>

    <div class="card">
        <h2>System Command Execution</h2>
        <button onclick="executeCommand()">Run Command</button>
        <pre id="commandOutput">Command output will appear here...</pre>
    </div>
</main>

<script>
    // Function to handle login authentication
    document.getElementById("authForm").addEventListener("submit", function(event) {
        event.preventDefault();
        
        const username = document.getElementById("username").value;
        const password = document.getElementById("password").value;

        // Call the back-end authentication service (this is just a simulation)
        fetch('/authenticate', {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ username, password })
        })
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                alert("Authentication successful!");
                // Proceed with showing additional data options
            } else {
                alert("Authentication failed!");
            }
        })
        .catch(error => console.error('Error during authentication:', error));
    });

    // Function to simulate fetching data
    function fetchData() {
        // Simulate fetching data (in a real case, it would be an API call to a Java backend)
        const data = [
            { id: 1, name: 'Item 1', details: 'Details for item 1' },
            { id: 2, name: 'Item 2', details: 'Details for item 2' },
            { id: 3, name: 'Item 3', details: 'Details for item 3' }
        ];

        const tableBody = document.querySelector('#dataTable tbody');
        tableBody.innerHTML = ''; // Clear any existing rows

        data.forEach(item => {
            const row = document.createElement('tr');
            row.innerHTML = `<td>${item.id}</td><td>${item.name}</td><td>${item.details}</td>`;
            tableBody.appendChild(row);
        });
    }

    // Function to simulate updating data
    function updateData() {
        alert('Data has been updated!');
        // Real-world scenario: Send an API request to update data on AS/400
    }

    // Function to simulate executing system command
    function executeCommand() {
        const commandOutput = "System command executed successfully!";
        document.getElementById('commandOutput').textContent = commandOutput;
        // Real-world scenario: Send an API request to execute an AS/400 system command
    }
</script>

</body>
</html>

2. Java Backend (API for Authentication and File Manipulation) The back-end part uses Java to handle authentication and file operations (connecting to AS/400 via JDBC or the IBM Toolbox for Java).

Example Java Code (Backend): For this, we use Spring Boot for the back-end API and assume you have the necessary libraries for AS/400 interaction.

Spring Boot Controller for Authentication:


@RestController
@RequestMapping("/api")
public class AS400Controller {

    // Example method to authenticate a user
    @PostMapping("/authenticate")
    public ResponseEntity<Map<String, Object>> authenticate(@RequestBody Map<String, String> credentials) {
        String username = credentials.get("username");
        String password = credentials.get("password");

        boolean isAuthenticated = authenticateUser(username, password);

        Map<String, Object> response = new HashMap<>();
        response.put("success", isAuthenticated);

        if (isAuthenticated) {
            // Perform any additional operations if needed
        } else {
            response.put("error", "Invalid username or password.");
        }

        return ResponseEntity.ok(response);
    }

    private boolean authenticateUser(String username, String password) {
        // Add your authentication logic here. E.g., using JDBC to validate against AS/400 system
        return "validUser".equals(username) && "validPassword".equals(password);
    }
}

JDBC Connection to AS/400 Database:


import java.sql.*;

public class AS400DatabaseService {

    private static final String JDBC_URL = "jdbc:as400://your_as400_system";
    private static final String USER = "your_username";
    private static final String PASSWORD = "your_password";

    // Method to fetch data from AS/400 database
    public List<String> fetchData() throws SQLException {
        List<String> data = new ArrayList<>();
        try (Connection connection = DriverManager.getConnection(JDBC_URL, USER, PASSWORD)) {
            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM your_table");

            while (rs.next()) {
                data.add(rs.getString("column_name"));
            }
        }
        return data;
    }

    // Method to perform file manipulation (e.g., creating files, appending data, etc.)
    public void manipulateFile() {
        // Your file manipulation logic here
        // E.g., using QSYS library to interact with system files
    }
}

3. JavaScript and HTML Integration: Authentication: JavaScript sends a POST request to /authenticate when the user logs in. The back-end responds with either success or failure, and JavaScript updates the UI accordingly. Data Fetching: Clicking the "Fetch Data" button in the HTML triggers a call to the back-end API to retrieve data from the AS/400 system. File Manipulation: Similarly, the "Update Data" button and "Run Command" button are placeholders for invoking system file operations and commands.

Conclusion: This setup uses HTML as the frontend to interface with users and Java (Spring Boot) as the backend to handle AS/400 database and file manipulation, including authentication. For actual production usage, you'd need to implement proper backend logic to securely connect to and interact with the AS/400 system, including error handling and secure password management.