File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass attribute from tag > action ?

 
John Summers
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 775
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic