1

Hi I have a jsp page in which following lines

if(Exception err) {
  out.println (err.getMessage() + "<br/><br/>");
}

may get XSS attacks i want to it just display the above things without any XSS attacks Any thought ?

scunliffe
  • 62,582
  • 25
  • 126
  • 161
Neeraj
  • 11
  • 3
  • 2
    unless I'm missing something (e.g. there is code you meant to post that got lost) there are no variables, parameters or SQL used in the above code that could be hijacked. – scunliffe Feb 24 '11 at 11:20
  • 2
    The code you've shown is not prone to XSS as there's nothing dynamic in it. Please post something more resembling your real code if you want help. – Don Roby Feb 24 '11 at 11:20
  • 1
    @scunlife, if err.getMessage() contains data from the user (ex. wrong input) than there is a possibility of XSS. – RealHowTo Feb 24 '11 at 12:25

2 Answers2

3

use c:out tag.

Also See

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
0

Apache Commons provides StringEscapeUtils, see the escapeHtml() method

RealHowTo
  • 34,977
  • 11
  • 70
  • 85