aspose file tools*
The moose likes Struts and the fly likes unable to access request attributes in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "unable to access request attributes in JSP" Watch "unable to access request attributes in JSP" New topic
Author

unable to access request attributes in JSP

Mohd Asim
Greenhorn

Joined: Jul 04, 2007
Posts: 24
I am setting a request attribute in a JSP:



in the action class, I am setting the request attribute once again:

the mapping for that action is as follows:


now when i try to access that attribute in my index.jsp


It shows up as null in the JSP. is something worng with the code?

Thanks in advance!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31078
    
233

Mohd,
In MVC, the JSP is the last thing that happens in a request. By the time you hit another action, the request is over and all your request attributes are gone. Which explains the null. Why not pass the value as a parameter to the action?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mohd Asim
Greenhorn

Joined: Jul 04, 2007
Posts: 24
So you mean that when I am setting the attribute in JSP like this



as soon as the link is clicked (index), I lose that attribute? And that attribute would not be available to the Action invoked by the link?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to access request attributes in JSP