• 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

Changing Scope dynamically

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a situation in which I have to change the scope from "request" to "session" in the action class. How could i get this functionality. I know that if i try to use the setScope method, i would get the error "configuration is freezed". What is the alternate way to achieve this. Any ideas


Thanks,
Shankar
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shankar,
You could copy the object from the request to the session. What are you trying to do? This seems like an awkward way of doing something.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds to me like he is asking how to change the scope of the action specified in the struts-config.xml. However, I am with you Jeanne. I am not sure what he is trying to do exactly or why. Maybe a bit more information about the scenerio would help.
 
Shankar Narayana
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to set the actionform into session scope due to some specific application requirements at some point in the action class. As you said I can copy from request to session, I tried it but didn't work for me.



This is my form bean which is in request scope at action level



If you could see the forward tag for "redirect" what it does is redirects to the original page "quoteheader.jsp" after displaying some message to the user, so I am using the javascript funtion "opener.location.reload". Now the "quoteheader.jsp" woudn't get the details from the actionForm as it a different request.

It would have got the details if the actionForm was in session scope. If I originally put the actionForm into session scope in struts-config.xml file, there are some other aspects which i have to take care and that is problamatic for me.

I have tried to put the actionForm into session in this way:

session.setAttribute("newReservationForm",newFormObj); and I hope the struts tags should be able to find the actionForm , which it is not doing.

I hope you are clear with what I am trying to do.

Thanks,
Shankar
[ September 02, 2004: Message edited by: Shankar Narayana ]
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Once the scope is set in struts-config u cant change as this will be loaded when the server is started....but even if use the trick of setting the bean in that particular scope u should use the tags by compulsorily saying scope="session/request" if u dont give this the way strust looks up is first applictaion/session/request and so conflict may happen .To avoid all this duplicate ur bean and put it in session/req with different name rather than the same ..........still u can use the struts tags
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic