-1

I have a web based project using spring mvc outputting into jsp's. I want to be able to type :) and have it replaced with a picture of my trainers face. How would I do this? I can't find any questions on here that are either relevant nor guides on the Internet.

Thanks, John

Andreas
  • 154,647
  • 11
  • 152
  • 247

1 Answers1

0

What you want to do is convert user entered text into HTML, then replace the :) string with an image of your trainers face.

Note: It's very important to escape text when displaying it again as HTML, in order to prevent cross-site scripting (XSS) attacks. Usually you use <c:out> to automatically do this escaping for you.

Since you want some HTML in the text, you can't use <c:out>, so you have to escape the rest of the text. See this page for ideas of how to do that: Best way to encode text data for XML in Java?

Then you replace the :) with an image tag: <img src="trainer.png">, and of course add that image file to your webapp.

Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247