Direct Product iff Nontrivial Idempotent

Theorem
Let $A$ be a commutative ring with unity.

Then $A$ is the direct product of two non-trivial rings if and only if $A$ contains an idempotent not equal to $0$ or $1$.

Proof
If $A$ has a nontrivial decomposition $A = A_1 \times A_2$ then $(1,0)$ is a non-trivial idempotent of $A$.

Conversely suppose there is $0,1 \neq e \in A$ with $e^2 = e$.

Let $A_1 = \langle e \rangle$, the ideal generated by $e$, and $A_2 = A / \langle e \rangle$.

Since $e(e-1) = 0$ $e$ is a zero divisor, by Unit Not Zero Divisor it is not a unit.

Therefore, $1 \notin A_1$ and $\langle e \rangle \subsetneqq A$.

Also $A_1 \cap A_2 = \{ 0 \}$ so the product is direct (that is, the Universal Property for Direct Products is satisfied)

Finally we define the "gluing homomorphism" $\phi : A \to A_1 \times A_2$ by


 * $ \phi : a \mapsto \left( ae, a + \langle e \rangle \right)$

which is easily shown to be an isomorphism.