4. Let the line $l$ with a slope of $\frac{\sqrt{2}}{2}$ intersect the ellipse $\frac{x^{2}}{a^{2}}+\frac{y^{2}}{b^{2}}=1$ $(a>b>0)$ at two distinct points $P$ and $Q$. If the projections of points $P$ and $Q$ on the $x$-axis are exactly the two foci of the ellipse, then the eccentricity of the ellipse is
4. $\frac{\sqrt{2}}{2}$.

Solution 1 Let the semi-focal distance of the ellipse be $c$.
As shown in Figure 5, it is easy to know that point $P\left(c, \frac{\sqrt{2}}{2} c\right)$. Then
$$
\begin{aligned}
& \frac{c^{2}}{a^{2}}+\frac{\left(\frac{\sqrt{2}}{2} c\right)^{2}}{b^{2}}=1 \\
\Rightarrow & \frac{c^{2}}{a^{2}}+\frac{c^{2}}{2\left(a^{2}-c^{2}\right)}=1 \\
\Rightarrow & e^{2}+\frac{e^{2}}{2\left(1-e^{2}\right)}=1 \\
\Rightarrow & e^{2}=2 \text { (discard) or } e^{2}=\frac{1}{2} \\
\Rightarrow & e=\frac{\sqrt{2}}{2} .
\end{aligned}
$$

Solution 2 From the given, we have $\left|P F_{2}\right|=\frac{\sqrt{2}}{2} c$. Thus,
$$
\left|P F_{1}\right|=\sqrt{\left|F_{1} F_{2}\right|^{2}+\left|P F_{2}\right|^{2}}=\frac{3 \sqrt{2}}{2} c \text {. }
$$

From $2 a=\left|P F_{1}\right|+\left|P F_{2}\right|=2 \sqrt{2} c$, we get $e=\frac{\sqrt{2}}{2}$.