How to pass parameters from Servlet via Bean to JSP page with the help of Session?

梦想的初衷 提交于 2019-12-05 16:34:30
BalusC

Get rid of the <jsp:useBean>. When using the type attribute instead of class, it won't check if there's already an instance in the scope, it will plain override the Person instance which you created in the servlet with a new, blank, default constructed instance.

When using "MVC architecture", the <jsp:useBean> tag is useless. Remove it and just use usual EL to access it:

${person.firstName} ${person.lastName}

Or better, to prevent XSS attacks, use JSTL <c:out>.

<c:out value="${person.firstName} ${person.lastName}" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!