Hi, I am designing a custom tag. In the doStartTag method i set an attribute: pageContext.setAttribute ("myCollection", collection, PageContext.SCOPE_SESSION); This tag is used on a particular jsp page. Now, once the page is rendered (this works ok) there is a form on the page. When the form is submitted my Action class is called ok, but in the execute method it cannot get the attribute by doing: Collection c = req.getSession().getAttribute("myCollection"); NB: Maybe a few typos here... Why can't it access the session attribute? Is there a way I can get this to happen?: 1) jsp page loads, custom tag handler is called and creates a session attribute 2) jsp page submits a form, the Action defined by the ActionMappings can access this attribute. thanks john
Reid M. Pinchback
posted 12 years ago
Create a logging statement in the tag and in the execute method. Print out the session ids in both cases. If the id is different, that is the source of the problem. If the ids are different it'll be because the client browser has never been given a chance to accept the newly-created session. This was an issue at one point in Tomcat, doesn't seem to be a factor in recent releases. Don't know about other web containers.