This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am trying to pass the Person object as an attribute request instance of a servlet. Then I am trying to catch that in JSP page using standard actions. When I use scope="request" I can access the values that I have sent from the servlet (i.e Anil, 18), But when I remove the scope (by default page scope) I cant access the object that i have sent from the servlet. It displays Ajay ,20.
Is there any possibility os sending attributes page scoped from the servlet. How to solve this problem. If I want to access the Anil,18 whethe I have to make scope="request" in standard actions.
The sevlet code:
The JSP code is
This is where the problem is. It is displaying Ajay, 20 (Initialized in JSP) Though I have passed the person attribute in request scope
Anil Deshpande wrote:
Is there any possibility os sending attributes page scoped from the servlet.
As far as i know, page scope should use in jsp side only.also you cant share it across the request . why you dont prefer request scope?
Joined: Jan 13, 2008
No problem with request scope. But I came to know that in jsp it basically makes use of findAttribute() method. So naturally the person attribute would be searched from request, session,context scope and so on. So according to that It sould be able to fing person attribute from request. Not directly initialize person because it doesn't locate it in page scope
But this is correct way...as you are setting object in request, it is better to use request to take it out.
In JSP you can set the any object in page scope using c:set [jstl].
Joined: Jan 13, 2008
I think I foud something that makes sense. By default it is always "page" scope in standard actions. If we want to access something from any other scope then we have to mention it explicitly like "request", "session" and so on. Am i right?
subject: unable to access requested scoped attribute in page scoped JSP