Issue in HttpSession

24 views
Skip to first unread message

Monica

unread,
Oct 9, 2012, 3:52:31 AM10/9/12
to arib...@googlegroups.com
Hi All,


I am using an Ariba project and i have given a link to navigate to another project which is a struts-jsp project. I want the Httpsession from Ariba in struts project but i am not getting it. Here is the code

In Main.groovy

public class Main extends AWComponent{

UserAccountIntf objUserAccountIntf = (UserAccountIntf)getBo();
UserAccount userInfo = new UserAccount()
userInfo = objUserAccountIntf.getUser()
request().getSession().setAttribute("userInfo",userInfo);

}

In Struts action class

public class SetupAction extends Action{

    public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception {
   
        UserAccount user = (UserAccount)request.getSession().getAttribute("userInfo");       
       
        return mapping.findForward("success");
    }
}
 
 here,
 
'request.getSession()'  is not matched with previous session.

Kindly help me.

Thanks
Monica

František Kolář

unread,
Oct 9, 2012, 4:37:13 AM10/9/12
to arib...@googlegroups.com
HI Monica, 

I am sure if you search the forum you will find something usefull. It has been long time ago I worked with struct and I am really happy I do not have to;-)  


I think we need to be aware of several things:

1)  We have several scopes inside one servlet application

2) You should think of sharing a servlet context not the session. 
  I am not sure from top of my head but I think servlet containers allows you to set servlet context to be crosscontext that allows you to share some of the resources. Please google
  
3) Two WARs uses completely different classloaders. Which means if you want to share your UserAccount Object they need to be exactly the same version and from the same classloader. 

4) From above you can see even if you have the same session (meaning its id) you can not really share objects. 


So sharing a data using servletContext is probably the way you want to go. This is your application scope. 




Regards

František Kolář 


--
You received this message because you are subscribed to the Google Groups "AribaWeb (aribaweb.org)" group.
To view this discussion on the web visit https://groups.google.com/d/msg/aribaweb/-/p6-wT9xOt8MJ.
To post to this group, send email to arib...@googlegroups.com.
To unsubscribe from this group, send email to aribaweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/aribaweb?hl=en.

monica zacharias

unread,
Oct 9, 2012, 6:28:20 AM10/9/12
to arib...@googlegroups.com
Hi František ,

Thanks for your reply. I am sorry currently I am using a single war , in which I have an Ariba part and jsp part. Are the both sessions same?
If so can you please define it.

Thanks 
Monica


František Kolář

unread,
Oct 9, 2012, 7:01:24 AM10/9/12
to arib...@googlegroups.com
Hi Monica, 

If you have single war and you can confirm that your session object is using the sam clasloader, then you can be able to put in this userdata. This is for sure.
You should then probably check out your framework. 
In case of AW when you ask for the session (request.getSession()), then the session is validated basically it searches some AW specific in the session. If its not found then the session is terminated and new one is created.  Please check out the AWRequest verifySessionIsValid().


Can you describe your usecase. 

1) you start your WAR-> who creates the session first time, your struts ? 
2) Do you have some servlet filters in place ? or your framework ? that could check also what is stored in the session ?
3)  First time you access AW application or structs ? Then there is some hyperlink that is invoked ?

I think this more about Servlet API than something AW specifics besides the fact that AW terminate the session if its initiated by AW. 

I think the fastest solution would be just to put the breakpoint in the invalidate  method or set get attribute, you will know who removes it. 



Regards

František Kolář 



--
You received this message because you are subscribed to the Google Groups "AribaWeb (aribaweb.org)" group.
Reply all
Reply to author
Forward
0 new messages