Difference between c:out and print the output using $

荒凉一梦 提交于 2019-12-22 04:36:26

问题


In JSTL there are two ways to print the output -

<H1><c:out value="${theOutput}" /></H1>

AND

<H1>${theOutput}</H1>

What is the difference? And which one is preferred way?

Thanks.


回答1:


Both methods c:out and JSP EL will display output to the page, however there is one major difference. The c:out tag will automatically escape xml output which can prevent cross site scripting. Using JSP EL (the second option) will not escape the output.

When displaying data which has been inputted by a user use the c:out tag instead of JSP EL to prevent any malicious data input from displaying on the page.



来源:https://stackoverflow.com/questions/18309728/difference-between-cout-and-print-the-output-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!