== Noncompliant Code Example

----
public String getTaintedValue(Connection con, HttpServletRequest request) throws SQLException {

  PreparedStatement pstmt = null;
  String query = "select TAINTED_VALUE " +
                 "from TAINTED_VALUES where KEY=?"
  try {
    pstmt = con.prepareStatement(query);
    pstmt.setString(1, request.getParameter("key"));  // PreparedStatements escape their inputs, so this incoming value is okay
    ResultSet rs = pstmt.executeQuery();
    while (rs.next()) {
      request.setAttribute("taintedValue",rs.getString("TAINTED_VALUE"));  // Noncompliant; this value should be escaped before being sent back to the user.
----
