The session you get from ActionContext is no HttpSession object.
You actually only get a java.util.Map containing all session parameters.
If you really need the HttpSession you should use the ServletConfigInterceptor.

Cheers
p

-----Ursprüngliche Nachricht-----
Von: remigijus [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 4. Dezember 2003 14:06
An: [EMAIL PROTECTED]
Betreff: Re: [OS-webwork] How to access session data from ActionClass


I tryed this way but I keep getting exceptions. Maybe I have missed somthing
in mu config settings.

Here is the code

    public String execute() throws Exception {
        ActionContext ctx = ActionContext.getContext();
        HttpSession session = (HttpSession) ctx.getSession(); // <<<<<< Here
I'm getting exception.
        SessionModel sessionModel;
        try {
            sessionModel = (SessionModel)
session.getAttribute("lt.uosis.SessionModel");
        } catch (Exception e) {
            sessionModel = new SessionModel();
            sessionModel.setSelectedCategoryId(id);
            session.setAttribute("lt.uosis.SessionModel", sessionModel);
        }

        return SUCCESS;
    }

and here is the exception:

SEVERE: Could not execute action
java.lang.ClassCastException
 at
lt.uosis.admin.action.OpenCategoryAction.execute(OpenCategoryAction.java:28)
 at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocatio
n.java:172)
 at
com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.intercept(Defa
ultWorkflowInterceptor.java:58)
 at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocatio
n.java:169)
 at
com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterce
ptor.java:37)
 at
com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocatio
n.java:169)


----- Original Message -----
From: "Jonas Eriksson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 04, 2003 2:53 PM
Subject: Re: [OS-webwork] How to access session data from ActionClass


> The session and application maps are accessed by using static methods of
> the ActionContext class.
>
> To get the session map you write
> Map session = ActionContext.getContext().getSession();
>
> Jonas
>
> remigijus wrote:
> > Hi
> >
> > How can get access to a session and application scope data from an
> > Action class.
> > If possible a little code sample, please.
> >
> > Remis
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to