0

I have created a servlet which creates and populates the values of a bean and also sets the bean as a session attribute and passes it to the jsp file. But when I retrieve the bean using the session object, I get null value. The jsp has been designed in such a way that the items from the database are saved in the bean file and passed to the jsp file which displays the database/bean values. This is in the doPost() method of the servlet:

        //Adding the list bean to the session
        session.setAttribute("list", list);

This is in the jsp file:

<%
MessageList list = (MessageList) request.getAttribute("list");
//The bean is of type 'MessageList'
%>
4

1 回答 1

2

您正在设置会话,但您正在从请求对象中检索。将第二位更改为session.getAttribute("list"),或将第一位更改为request.setAttribute("list", list)

于 2012-09-15T10:51:46.447 回答