Web Application Security: Threats, Countermeasures, and Pitfalls