# Getting Started

## What This Project Does

This is a Java web application built on **Jakarta EE** (JavaServer Faces) called **KoptWebA**. It serves web pages through JSPs backed by managed beans and view logic classes. A request filter handles ShiftJis character encoding for Japanese-language pages, and the app context listener manages application lifecycle events.

## Recommended Reading Order

1. **[Project Structure](#project-structure)** — understand how the codebase is laid out
2. **[Key Entry Points](#key-entry-points)** — follow the request flow from servlet to bean
3. **[Configuration](#configuration)** — review `web-full.xml` to understand how the web tier is wired

## Key Entry Points

The application follows a standard JSF request flow. Start here:

### X33JVRequestEncodingSjisFilter

Path: `src/java/com/fujitsu/futurity/web/x33/filter/X33JVRequestEncodingSjisFilter.java`

This servlet filter is the first request handler. It intercepts incoming HTTP requests and sets the character encoding to ShiftJis before passing the request down the chain. It is registered in `web-full.xml` and runs for every request.

### FacesServlet

Path: `src/java/javax/webapp/FacesServlet.java`

The JSF FacesServlet dispatches requests to the JSF lifecycle. After the encoding filter runs, the FacesServlet manages the JSF phase lifecycle (Restore View, Apply Request Values, Process Validations, Update Model, Invoke Application, Render Response).

### ACA001SFBean

Path: `src/java/eo/web/webview/ACA001SF/ACA001SFBean.java`

The most referenced class in the codebase (10 connections). This is a JSF managed bean in the `eo.web.webview.ACA001SF` package. It acts as the data carrier between JSP views and the backing logic. It follows the Java Bean convention with a `value` property and a `getValue()` getter.

### ACA001SFLogic

Path: `src/java/eo/web/webview/ACA001SF/ACA001SFLogic.java`

The backing logic class paired with `ACA001SFBean`. It contains the business method `execute()` that the bean delegates to. This Bean-Logic split pattern is used throughout the application.

## Request Flow

```mermaid
flowchart TD
    Client["Web Browser"] --> Web["Web Tier: KoptWebA"]
    Web --> Filter["X33JVRequestEncodingSjisFilter"]
    Filter --> Faces["FacesServlet"]
    Faces --> Bean["ACA001SFBean"]
    Bean --> Logic["ACA001SFLogic"]
    Logic --> JSP["JSP Pages"]
    JSP --> Client
```

## Project Structure

```mermaid
flowchart TD
    Source["src"] --> Java["src/java"]
    Source --> App["src/futurity-app"]
    Java --> Eo["eo/web/webview"]
    Java --> Fujitsu["com/fujitsu/futurity"]
    Java --> Javax["javax/webapp"]
    App --> Env["webA/env/view/def"]
    Eo --> ACA001["ACA001SF package"]
    Fujitsu --> Filter["x33/filter"]
    Fujitsu --> Listener["x33/listener"]
```

The source tree has three main areas:

- **`src/java/eo/web/webview/`** — Application-specific JSF beans and logic classes. This is where business-facing view components live (e.g. `ACA001SF` package).
- **`src/java/com/fujitsu/futurity/`** — Framework-level infrastructure: the ShiftJis encoding filter and the application context listener.
- **`src/java/javax/webapp/`** — JSF FacesServlet wrapper.
- **`src/futurity-app/webA/env/view/def/`** — View definition XML files (e.g. `WEBGAMEN_FULL_ACA001.xml`) that configure page layouts and navigation.

Web resources (JSPs, fragment includes) live under `koptWebA/WebContent/`:

- **`koptWebA/WebContent/wsd/`** — JSP pages for the "web system demo" module. Includes test pages like `usebean.jsp`, `multi-usebean.jsp`, `wildcard.jsp`, and `comment-only.jsp`.
- **`koptWebA/WebContent/wsd/ns/jpn/pc/`** — Japanese PC-specific JSP pages.
- **`koptWebA/WebContent/wsd/fragments/header.jspf`** — Shared JSP fragment for reusable page sections.

## Configuration

### web-full.xml

Path: `koptWebA/WebContent/WEB-INF/web-full.xml`

The main web deployment descriptor. It declares:

- **`SjisFilter`** — maps to `X33JVRequestEncodingSjisFilter` (ShiftJis character encoding).
- **`FacesServlet`** — maps to `javax.faces.webapp.FacesServlet` (JSF request dispatcher).

When you modify the web tier (add filters, servlets, or mapping), update this file.

### View Definitions

Path: `src/futurity-app/webA/env/view/def/`

XML files here define page compositions and navigation rules for JSF views. The naming convention follows the pattern `WEBGAMEN_<PAGE_ID>.xml`.

### Environment Config

Path: `src/futurity-app/webA/env/view/`

Environment-specific overrides for view configuration.

## Common Patterns

### Bean-Logic Split

Business methods never live in managed beans. Every screen has a pair:

```
Package: eo.web.webview.<ScreenID>
  <ScreenID>Bean.java          -- data holder with getters/setters
  <ScreenID>Logic.java         -- contains the execute() method with logic
```

Example: `ACA001SFBean` delegates to `ACA001SFLogic.execute()`.

### ShiftJis Encoding

All incoming requests are forced through `X33JVRequestEncodingSjisFilter`. Japanese language JSPs in `wsd/ns/jpn/pc/` expect this encoding. Do not bypass the filter.

### JSP Page Imports

JSP pages use `<%@ page import="..." >` and `<jsp:useBean>` to reference beans. Common import patterns:

- **Single class**: `import="eo.web.webview.ACA001SF.ACA001SFBean"`
- **Wildcards**: `import="com.fujitsu.futurity.web.x33.beans.*"`
- **Multiple beans per page**: `<jsp:useBean id="bean1" .../>` and `<jsp:useBean id="bean2" .../>` with different scopes (`request`, `session`)

### JSP Fragments

Shared UI components live as `.jspf` files (e.g., `header.jspf` under `wsd/fragments/`). Include them with `<jsp:include>` to avoid duplication across pages.
