• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to access requested scoped attribute in page scoped JSP

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


Please help.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?

 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anil Deshpande wrote: But I came to know that in jsp it basically makes use of findAttribute() method.



Not jsp. pageContext (implicit object) has the findAttribute method
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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].
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic