How to add slashes to a particular string in JSP? I want to convert this PHP code $subj = addslashes($_POST['txtsubjct']);
to JSP.
addslashes()
is not particularly needed:
If you want to protect from sql-injections, use PreparedStatement
public static String addSlashes(String s) {
s = s.replaceAll("\\\\", "\\\\\\\\");
s = s.replaceAll("\\n", "\\\\n");
s = s.replaceAll("\\r", "\\\\r");
s = s.replaceAll("\\00", "\\\\0");
s = s.replaceAll("'", "\\\\'");
return s;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.