Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I presume that you're using JSP. </p> <p>Just escape during <strong>display</strong> only. There for the <a href="http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/" rel="noreferrer">JSTL</a> <a href="http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/out.html" rel="noreferrer"><code>&lt;c:out&gt;</code></a> tag is perfectly suitable. It escapes HTML entities by default. Use it to display <em>every</em> user-controlled input, such as request URL, request headers and request parameters.</p> <p>E.g.</p> <pre><code>&lt;input type="text" name="foo" value="&lt;c:out value="${param.foo}" /&gt;"&gt; </code></pre> <p>Escaping during input is not needed. <a href="http://ha.ckers.org/xss.html" rel="noreferrer">XSS</a> doesn't harm in raw Java code nor in SQL databases. On the other hand, you would also rather save data unmodified in DB so that you can still see what the user <em>actually</em> entered, so that you can if necessary do social actions on mailicious users.</p> <p>If you'd like to know what to escape during input, it would be <a href="http://unixwiz.net/techtips/sql-injection.html" rel="noreferrer">SQL injection</a>. In such case just use <a href="http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html" rel="noreferrer"><code>PreparedStatement</code></a> instead of regular <code>Statement</code> whenever you want to save <em>any</em> user-controlled input in the database.</p> <p>E.g.</p> <pre><code>create = connection.prepareStatement("INSERT INTO user (username, password) VALUES (?, MD5(?))"); create.setString(1, username); create.setString(2, password); create.executeUpdate(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload