htmlspecialchars for jsp

Solutions on MaxInterview for htmlspecialchars for jsp by the best coders in the world

showing results for - "htmlspecialchars for jsp"
Leonardo
03 Sep 2019
1StringBuffer sb = new StringBuffer();
2
3for(int i=0; i<content.length(); i++){
4
5char c = content.charAt(i);
6
7  switch (c) {
8
9    case '<' : 
10
11      sb.append("&lt;");
12
13      break;
14
15    case '>' : 
16
17      sb.append("&gt;");
18
19      break;
20
21    case '&' :
22
23      sb.append("&amp;");
24
25      break;
26
27    case '"' :
28
29      sb.append("&quot;");
30
31      break;
32
33    case '\'' :
34
35      sb.append("&apos;");
36
37      break;
38
39    default:
40
41      sb.append(c);
42
43	}
44
45}
46
47