Does Java have standard functions for security like in php htmlspecialchars, strip_tags? Or must I write my own functions? I want to be sure my script handles user data safely.
Does Java have standard functions for security like in php htmlspecialchars , strip_tags ?
Share
Not exactly.
Protection against injection attacks in Java comes “for free” provided that you do certain things the right way. For example:
Don’t create SQL by concatenating strings. Instead, create your SQL with placeholders, and compile / execute using JDBC
PreparedStatement.In JSPs, use
<c:out>to output any data that comes from the user. This automatically HTML escapes it to denature any potential injected nasties.