You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sergio <ki...@hotmail.com> on 2010/01/05 17:53:14 UTC

problems with struts2 and session

Hi people,

i'm a newbie to struts2. I'm having too many problems modifing session 
parameters. I use <%= session.getAttribute( "variable" ) %> to gain 
access to "variable" and that works when i modify "variable" into a jsp 
page, but not inside a struts action.

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
   "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

   <constant name="struts.enable.DynamicMethodInvocation" value="false" />
   <constant name="struts.devMode" value="true" />

<package name="tads" namespace="/" extends="struts-default">

<action name="HolaMundo" class="tads.HolaMundo">
<result>/holaMundo.jsp</result>
</action>

<action name="Catalogo" class="tads.Catalogo">
     <result  name="error">/ErrorCatalogo.jsp</result>
     <result>/Catalogo.jsp</result>
   </action>

<action name="Actualiza" class="tads.Actualiza">
     <result>/Actualiza.jsp</result>
   </action>



</package>

</struts>

extract from a jsp page, result from an ajax action working:

<s:form id="form" >
                 <s:textfield name="politico" label="politico"/><br>   
                 <s:hidden name="prueba" value="escondido" />
               </s:form>
               <s:url id="actualiza" value="/Actualiza.action" />

<sx:submit type="button" label="dale" href="%{actualiza}" formId="form" 
align="center" targets="secondaryContent"/>

i see "politico" and "prueba" into Actualiza.action so the action 
Actualiza works.

Actualiza.java:

package tads;
import java.util.*;

import javax.servlet.http.HttpSession;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;


@SuppressWarnings("serial")
public class Actualiza extends ActionSupport implements SessionAware {
   private String politico;
   private String prueba;
   private Map session;
     public String execute() throws Exception {
 
       this.getSession().put("variable","pruebamil");
       return SUCCESS;
       }
   public String getPolitico() {
       return politico;
   }

   public void setPolitico(String politico) {
       this.politico = politico;
   }

   public String getPrueba() {
       return prueba;
   }

   public void setPrueba(String prueba) {
       this.prueba = prueba;
   }
   public void setSession(Map session) {
       this.session = session;
     }
         public Map getSession() {
       return session;
     }
}

in that situation. Actualiza.jsp doesn't show "variable" atribute from 
session, using "<%= session.getAttribute( "variable" ) %>". It shows null.

can anybody help me? I'm doing exactly what struts2 FAQ say (How do we 
get access to the session).

thanks in advance.

-- 
Sergio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Sergio,
this time late answear,
when You have session field in action and also setter and getter for it
then You can access session map as any other field from action in jsp,
so < s:property value="session.get('variable')" > should work,
because it is accessing normal getter in stack.
Maybe try < s:property value="getSession().get('variable')" > to be
more accurate.

Best greetings,
Paweł Wielgus.



2010/1/6 Sergio <ki...@hotmail.com>:
> Paweł Wielgus escribió:
>>
>> Hi,
>> sorry for too fast response,
>> i see that it is implementing it,
>> another thing to notice is that
>> in action You have access to session field which is a map constructed
>> by struts, not real session object - as far as i remember.
>> In jsp you can do < s:property value="session.get('variable')" > to
>> show key from session in jsp.
>>
>> Hope that it will help,
>> Pawel Wielgus.
>>
>> 2010/1/6, Sergio <ki...@hotmail.com>:
>>
>>>
>>> Paweł Wielgus escribió:
>>>
>>>>
>>>> Hi Sergio,
>>>> add SessionAware interface to your action.
>>>>
>>>> Best greetings,
>>>> Pawel Wielgus.
>>>>
>>>> 2010/1/5, Sergio <ki...@hotmail.com>:
>>>>
>>>>
>>>>>
>>>>> Sergio escribió:
>>>>>
>>>>>
>>>>>>
>>>>>> Hi people,
>>>>>>
>>>>>> i'm a newbie to struts2. I'm having too many problems modifing session
>>>>>> parameters. I use <%= session.getAttribute( "variable" ) %> to gain
>>>>>> access to "variable" and that works when i modify "variable" into a
>>>>>> jsp page, but not inside a struts action.
>>>>>>
>>>>>> struts.xml:
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8" ?>
>>>>>> <!DOCTYPE struts PUBLIC
>>>>>>  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>>>>  "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>>>>
>>>>>> <struts>
>>>>>>
>>>>>>  <constant name="struts.enable.DynamicMethodInvocation" value="false"
>>>>>> />
>>>>>>  <constant name="struts.devMode" value="true" />
>>>>>>
>>>>>> <package name="tads" namespace="/" extends="struts-default">
>>>>>>
>>>>>> <action name="HolaMundo" class="tads.HolaMundo">
>>>>>> <result>/holaMundo.jsp</result>
>>>>>> </action>
>>>>>>
>>>>>> <action name="Catalogo" class="tads.Catalogo">
>>>>>>    <result  name="error">/ErrorCatalogo.jsp</result>
>>>>>>    <result>/Catalogo.jsp</result>
>>>>>>  </action>
>>>>>>
>>>>>> <action name="Actualiza" class="tads.Actualiza">
>>>>>>    <result>/Actualiza.jsp</result>
>>>>>>  </action>
>>>>>>
>>>>>>
>>>>>>
>>>>>> </package>
>>>>>>
>>>>>> </struts>
>>>>>>
>>>>>> extract from a jsp page, result from an ajax action working:
>>>>>>
>>>>>> <s:form id="form" >
>>>>>>                <s:textfield name="politico" label="politico"/><br>
>>>>>>                <s:hidden name="prueba" value="escondido" />
>>>>>>              </s:form>
>>>>>>              <s:url id="actualiza" value="/Actualiza.action" />
>>>>>>
>>>>>> <sx:submit type="button" label="dale" href="%{actualiza}"
>>>>>> formId="form" align="center" targets="secondaryContent"/>
>>>>>>
>>>>>> i see "politico" and "prueba" into Actualiza.action so the action
>>>>>> Actualiza works.
>>>>>>
>>>>>> Actualiza.java:
>>>>>>
>>>>>> package tads;
>>>>>> import java.util.*;
>>>>>>
>>>>>> import javax.servlet.http.HttpSession;
>>>>>> import com.opensymphony.xwork2.ActionSupport;
>>>>>> import org.apache.struts2.interceptor.SessionAware;
>>>>>> import com.opensymphony.xwork2.ActionContext;
>>>>>>
>>>>>>
>>>>>> @SuppressWarnings("serial")
>>>>>> public class Actualiza extends ActionSupport implements SessionAware {
>>>>>>  private String politico;
>>>>>>  private String prueba;
>>>>>>  private Map session;
>>>>>>    public String execute() throws Exception {
>>>>>>
>>>>>>      this.getSession().put("variable","pruebamil");
>>>>>>      return SUCCESS;
>>>>>>      }
>>>>>>  public String getPolitico() {
>>>>>>      return politico;
>>>>>>  }
>>>>>>
>>>>>>  public void setPolitico(String politico) {
>>>>>>      this.politico = politico;
>>>>>>  }
>>>>>>
>>>>>>  public String getPrueba() {
>>>>>>      return prueba;
>>>>>>  }
>>>>>>
>>>>>>  public void setPrueba(String prueba) {
>>>>>>      this.prueba = prueba;
>>>>>>  }
>>>>>>  public void setSession(Map session) {
>>>>>>      this.session = session;
>>>>>>    }
>>>>>>        public Map getSession() {
>>>>>>      return session;
>>>>>>    }
>>>>>> }
>>>>>>
>>>>>> in that situation. Actualiza.jsp doesn't show "variable" atribute from
>>>>>> session, using "<%= session.getAttribute( "variable" ) %>". It shows
>>>>>> null.
>>>>>>
>>>>>> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we
>>>>>> get access to the session).
>>>>>>
>>>>>> thanks in advance.
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> i've tried with
>>>>>
>>>>>      <%= session.getAttribute( "variable" ) %>
>>>>>
>>>>> and
>>>>>
>>>>>      <s:property value="#session.variable"></s:property>
>>>>>
>>>>> and surprise, both works. After closing and opening eclipse 3.4.0
>>>>> works.
>>>>> I think this is a bad memory managing of eclipse. Does anybody knows
>>>>> something about this?
>>>>>
>>>>> --
>>>>> Sergio
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> public class Actualiza extends ActionSupport implements SessionAware
>>>
>>> is that?
>>>
>>> thanks for replying
>>>
>>>
>>> --
>>> Sergio
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>
> as far as i remember :) "< s:property value="session.get('variable')" >"
> didn't work because the "get" method. Both "<%= session.getAttribute(
> "variable" ) %>" and "<s:property value="#session.variable"></s:property>"
> worked, but i had to close and open eclipse. Bad memory management of
> eclipse i think.
>
> thanks for your fast reply :)
>
> --
> Sergio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Sergio <ki...@hotmail.com>.
Paweł Wielgus escribió:
> Hi,
> sorry for too fast response,
> i see that it is implementing it,
> another thing to notice is that
> in action You have access to session field which is a map constructed
> by struts, not real session object - as far as i remember.
> In jsp you can do < s:property value="session.get('variable')" > to
> show key from session in jsp.
>
> Hope that it will help,
> Pawel Wielgus.
>
> 2010/1/6, Sergio <ki...@hotmail.com>:
>   
>> Paweł Wielgus escribió:
>>     
>>> Hi Sergio,
>>> add SessionAware interface to your action.
>>>
>>> Best greetings,
>>> Pawel Wielgus.
>>>
>>> 2010/1/5, Sergio <ki...@hotmail.com>:
>>>
>>>       
>>>> Sergio escribió:
>>>>
>>>>         
>>>>> Hi people,
>>>>>
>>>>> i'm a newbie to struts2. I'm having too many problems modifing session
>>>>> parameters. I use <%= session.getAttribute( "variable" ) %> to gain
>>>>> access to "variable" and that works when i modify "variable" into a
>>>>> jsp page, but not inside a struts action.
>>>>>
>>>>> struts.xml:
>>>>>
>>>>> <?xml version="1.0" encoding="UTF-8" ?>
>>>>> <!DOCTYPE struts PUBLIC
>>>>>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>>>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>>>
>>>>> <struts>
>>>>>
>>>>>   <constant name="struts.enable.DynamicMethodInvocation" value="false"
>>>>> />
>>>>>   <constant name="struts.devMode" value="true" />
>>>>>
>>>>> <package name="tads" namespace="/" extends="struts-default">
>>>>>
>>>>> <action name="HolaMundo" class="tads.HolaMundo">
>>>>> <result>/holaMundo.jsp</result>
>>>>> </action>
>>>>>
>>>>> <action name="Catalogo" class="tads.Catalogo">
>>>>>     <result  name="error">/ErrorCatalogo.jsp</result>
>>>>>     <result>/Catalogo.jsp</result>
>>>>>   </action>
>>>>>
>>>>> <action name="Actualiza" class="tads.Actualiza">
>>>>>     <result>/Actualiza.jsp</result>
>>>>>   </action>
>>>>>
>>>>>
>>>>>
>>>>> </package>
>>>>>
>>>>> </struts>
>>>>>
>>>>> extract from a jsp page, result from an ajax action working:
>>>>>
>>>>> <s:form id="form" >
>>>>>                 <s:textfield name="politico" label="politico"/><br>
>>>>>                 <s:hidden name="prueba" value="escondido" />
>>>>>               </s:form>
>>>>>               <s:url id="actualiza" value="/Actualiza.action" />
>>>>>
>>>>> <sx:submit type="button" label="dale" href="%{actualiza}"
>>>>> formId="form" align="center" targets="secondaryContent"/>
>>>>>
>>>>> i see "politico" and "prueba" into Actualiza.action so the action
>>>>> Actualiza works.
>>>>>
>>>>> Actualiza.java:
>>>>>
>>>>> package tads;
>>>>> import java.util.*;
>>>>>
>>>>> import javax.servlet.http.HttpSession;
>>>>> import com.opensymphony.xwork2.ActionSupport;
>>>>> import org.apache.struts2.interceptor.SessionAware;
>>>>> import com.opensymphony.xwork2.ActionContext;
>>>>>
>>>>>
>>>>> @SuppressWarnings("serial")
>>>>> public class Actualiza extends ActionSupport implements SessionAware {
>>>>>   private String politico;
>>>>>   private String prueba;
>>>>>   private Map session;
>>>>>     public String execute() throws Exception {
>>>>>
>>>>>       this.getSession().put("variable","pruebamil");
>>>>>       return SUCCESS;
>>>>>       }
>>>>>   public String getPolitico() {
>>>>>       return politico;
>>>>>   }
>>>>>
>>>>>   public void setPolitico(String politico) {
>>>>>       this.politico = politico;
>>>>>   }
>>>>>
>>>>>   public String getPrueba() {
>>>>>       return prueba;
>>>>>   }
>>>>>
>>>>>   public void setPrueba(String prueba) {
>>>>>       this.prueba = prueba;
>>>>>   }
>>>>>   public void setSession(Map session) {
>>>>>       this.session = session;
>>>>>     }
>>>>>         public Map getSession() {
>>>>>       return session;
>>>>>     }
>>>>> }
>>>>>
>>>>> in that situation. Actualiza.jsp doesn't show "variable" atribute from
>>>>> session, using "<%= session.getAttribute( "variable" ) %>". It shows
>>>>> null.
>>>>>
>>>>> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we
>>>>> get access to the session).
>>>>>
>>>>> thanks in advance.
>>>>>
>>>>>
>>>>>           
>>>> i've tried with
>>>>
>>>>       <%= session.getAttribute( "variable" ) %>
>>>>
>>>> and
>>>>
>>>>       <s:property value="#session.variable"></s:property>
>>>>
>>>> and surprise, both works. After closing and opening eclipse 3.4.0 works.
>>>> I think this is a bad memory managing of eclipse. Does anybody knows
>>>> something about this?
>>>>
>>>> --
>>>> Sergio
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>>       
>> public class Actualiza extends ActionSupport implements SessionAware
>>
>> is that?
>>
>> thanks for replying
>>
>>
>> --
>> Sergio
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>   
as far as i remember :) "< s:property value="session.get('variable')" >" 
didn't work because the "get" method. Both "<%= session.getAttribute( 
"variable" ) %>" and "<s:property 
value="#session.variable"></s:property>" worked, but i had to close and 
open eclipse. Bad memory management of eclipse i think.

thanks for your fast reply :)

-- 
Sergio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
sorry for too fast response,
i see that it is implementing it,
another thing to notice is that
in action You have access to session field which is a map constructed
by struts, not real session object - as far as i remember.
In jsp you can do < s:property value="session.get('variable')" > to
show key from session in jsp.

Hope that it will help,
Pawel Wielgus.

2010/1/6, Sergio <ki...@hotmail.com>:
> Paweł Wielgus escribió:
>> Hi Sergio,
>> add SessionAware interface to your action.
>>
>> Best greetings,
>> Pawel Wielgus.
>>
>> 2010/1/5, Sergio <ki...@hotmail.com>:
>>
>>> Sergio escribió:
>>>
>>>> Hi people,
>>>>
>>>> i'm a newbie to struts2. I'm having too many problems modifing session
>>>> parameters. I use <%= session.getAttribute( "variable" ) %> to gain
>>>> access to "variable" and that works when i modify "variable" into a
>>>> jsp page, but not inside a struts action.
>>>>
>>>> struts.xml:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8" ?>
>>>> <!DOCTYPE struts PUBLIC
>>>>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>>
>>>> <struts>
>>>>
>>>>   <constant name="struts.enable.DynamicMethodInvocation" value="false"
>>>> />
>>>>   <constant name="struts.devMode" value="true" />
>>>>
>>>> <package name="tads" namespace="/" extends="struts-default">
>>>>
>>>> <action name="HolaMundo" class="tads.HolaMundo">
>>>> <result>/holaMundo.jsp</result>
>>>> </action>
>>>>
>>>> <action name="Catalogo" class="tads.Catalogo">
>>>>     <result  name="error">/ErrorCatalogo.jsp</result>
>>>>     <result>/Catalogo.jsp</result>
>>>>   </action>
>>>>
>>>> <action name="Actualiza" class="tads.Actualiza">
>>>>     <result>/Actualiza.jsp</result>
>>>>   </action>
>>>>
>>>>
>>>>
>>>> </package>
>>>>
>>>> </struts>
>>>>
>>>> extract from a jsp page, result from an ajax action working:
>>>>
>>>> <s:form id="form" >
>>>>                 <s:textfield name="politico" label="politico"/><br>
>>>>                 <s:hidden name="prueba" value="escondido" />
>>>>               </s:form>
>>>>               <s:url id="actualiza" value="/Actualiza.action" />
>>>>
>>>> <sx:submit type="button" label="dale" href="%{actualiza}"
>>>> formId="form" align="center" targets="secondaryContent"/>
>>>>
>>>> i see "politico" and "prueba" into Actualiza.action so the action
>>>> Actualiza works.
>>>>
>>>> Actualiza.java:
>>>>
>>>> package tads;
>>>> import java.util.*;
>>>>
>>>> import javax.servlet.http.HttpSession;
>>>> import com.opensymphony.xwork2.ActionSupport;
>>>> import org.apache.struts2.interceptor.SessionAware;
>>>> import com.opensymphony.xwork2.ActionContext;
>>>>
>>>>
>>>> @SuppressWarnings("serial")
>>>> public class Actualiza extends ActionSupport implements SessionAware {
>>>>   private String politico;
>>>>   private String prueba;
>>>>   private Map session;
>>>>     public String execute() throws Exception {
>>>>
>>>>       this.getSession().put("variable","pruebamil");
>>>>       return SUCCESS;
>>>>       }
>>>>   public String getPolitico() {
>>>>       return politico;
>>>>   }
>>>>
>>>>   public void setPolitico(String politico) {
>>>>       this.politico = politico;
>>>>   }
>>>>
>>>>   public String getPrueba() {
>>>>       return prueba;
>>>>   }
>>>>
>>>>   public void setPrueba(String prueba) {
>>>>       this.prueba = prueba;
>>>>   }
>>>>   public void setSession(Map session) {
>>>>       this.session = session;
>>>>     }
>>>>         public Map getSession() {
>>>>       return session;
>>>>     }
>>>> }
>>>>
>>>> in that situation. Actualiza.jsp doesn't show "variable" atribute from
>>>> session, using "<%= session.getAttribute( "variable" ) %>". It shows
>>>> null.
>>>>
>>>> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we
>>>> get access to the session).
>>>>
>>>> thanks in advance.
>>>>
>>>>
>>> i've tried with
>>>
>>>       <%= session.getAttribute( "variable" ) %>
>>>
>>> and
>>>
>>>       <s:property value="#session.variable"></s:property>
>>>
>>> and surprise, both works. After closing and opening eclipse 3.4.0 works.
>>> I think this is a bad memory managing of eclipse. Does anybody knows
>>> something about this?
>>>
>>> --
>>> Sergio
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
>
> public class Actualiza extends ActionSupport implements SessionAware
>
> is that?
>
> thanks for replying
>
>
> --
> Sergio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Sergio <ki...@hotmail.com>.
Paweł Wielgus escribió:
> Hi Sergio,
> add SessionAware interface to your action.
>
> Best greetings,
> Pawel Wielgus.
>
> 2010/1/5, Sergio <ki...@hotmail.com>:
>   
>> Sergio escribió:
>>     
>>> Hi people,
>>>
>>> i'm a newbie to struts2. I'm having too many problems modifing session
>>> parameters. I use <%= session.getAttribute( "variable" ) %> to gain
>>> access to "variable" and that works when i modify "variable" into a
>>> jsp page, but not inside a struts action.
>>>
>>> struts.xml:
>>>
>>> <?xml version="1.0" encoding="UTF-8" ?>
>>> <!DOCTYPE struts PUBLIC
>>>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>
>>> <struts>
>>>
>>>   <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>>>   <constant name="struts.devMode" value="true" />
>>>
>>> <package name="tads" namespace="/" extends="struts-default">
>>>
>>> <action name="HolaMundo" class="tads.HolaMundo">
>>> <result>/holaMundo.jsp</result>
>>> </action>
>>>
>>> <action name="Catalogo" class="tads.Catalogo">
>>>     <result  name="error">/ErrorCatalogo.jsp</result>
>>>     <result>/Catalogo.jsp</result>
>>>   </action>
>>>
>>> <action name="Actualiza" class="tads.Actualiza">
>>>     <result>/Actualiza.jsp</result>
>>>   </action>
>>>
>>>
>>>
>>> </package>
>>>
>>> </struts>
>>>
>>> extract from a jsp page, result from an ajax action working:
>>>
>>> <s:form id="form" >
>>>                 <s:textfield name="politico" label="politico"/><br>
>>>                 <s:hidden name="prueba" value="escondido" />
>>>               </s:form>
>>>               <s:url id="actualiza" value="/Actualiza.action" />
>>>
>>> <sx:submit type="button" label="dale" href="%{actualiza}"
>>> formId="form" align="center" targets="secondaryContent"/>
>>>
>>> i see "politico" and "prueba" into Actualiza.action so the action
>>> Actualiza works.
>>>
>>> Actualiza.java:
>>>
>>> package tads;
>>> import java.util.*;
>>>
>>> import javax.servlet.http.HttpSession;
>>> import com.opensymphony.xwork2.ActionSupport;
>>> import org.apache.struts2.interceptor.SessionAware;
>>> import com.opensymphony.xwork2.ActionContext;
>>>
>>>
>>> @SuppressWarnings("serial")
>>> public class Actualiza extends ActionSupport implements SessionAware {
>>>   private String politico;
>>>   private String prueba;
>>>   private Map session;
>>>     public String execute() throws Exception {
>>>
>>>       this.getSession().put("variable","pruebamil");
>>>       return SUCCESS;
>>>       }
>>>   public String getPolitico() {
>>>       return politico;
>>>   }
>>>
>>>   public void setPolitico(String politico) {
>>>       this.politico = politico;
>>>   }
>>>
>>>   public String getPrueba() {
>>>       return prueba;
>>>   }
>>>
>>>   public void setPrueba(String prueba) {
>>>       this.prueba = prueba;
>>>   }
>>>   public void setSession(Map session) {
>>>       this.session = session;
>>>     }
>>>         public Map getSession() {
>>>       return session;
>>>     }
>>> }
>>>
>>> in that situation. Actualiza.jsp doesn't show "variable" atribute from
>>> session, using "<%= session.getAttribute( "variable" ) %>". It shows
>>> null.
>>>
>>> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we
>>> get access to the session).
>>>
>>> thanks in advance.
>>>
>>>       
>> i've tried with
>>
>>       <%= session.getAttribute( "variable" ) %>
>>
>> and
>>
>>       <s:property value="#session.variable"></s:property>
>>
>> and surprise, both works. After closing and opening eclipse 3.4.0 works.
>> I think this is a bad memory managing of eclipse. Does anybody knows
>> something about this?
>>
>> --
>> Sergio
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>   

public class Actualiza extends ActionSupport implements SessionAware

is that?

thanks for replying


-- 
Sergio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Sergio,
add SessionAware interface to your action.

Best greetings,
Pawel Wielgus.

2010/1/5, Sergio <ki...@hotmail.com>:
> Sergio escribió:
>> Hi people,
>>
>> i'm a newbie to struts2. I'm having too many problems modifing session
>> parameters. I use <%= session.getAttribute( "variable" ) %> to gain
>> access to "variable" and that works when i modify "variable" into a
>> jsp page, but not inside a struts action.
>>
>> struts.xml:
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <!DOCTYPE struts PUBLIC
>>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>>
>> <struts>
>>
>>   <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>>   <constant name="struts.devMode" value="true" />
>>
>> <package name="tads" namespace="/" extends="struts-default">
>>
>> <action name="HolaMundo" class="tads.HolaMundo">
>> <result>/holaMundo.jsp</result>
>> </action>
>>
>> <action name="Catalogo" class="tads.Catalogo">
>>     <result  name="error">/ErrorCatalogo.jsp</result>
>>     <result>/Catalogo.jsp</result>
>>   </action>
>>
>> <action name="Actualiza" class="tads.Actualiza">
>>     <result>/Actualiza.jsp</result>
>>   </action>
>>
>>
>>
>> </package>
>>
>> </struts>
>>
>> extract from a jsp page, result from an ajax action working:
>>
>> <s:form id="form" >
>>                 <s:textfield name="politico" label="politico"/><br>
>>                 <s:hidden name="prueba" value="escondido" />
>>               </s:form>
>>               <s:url id="actualiza" value="/Actualiza.action" />
>>
>> <sx:submit type="button" label="dale" href="%{actualiza}"
>> formId="form" align="center" targets="secondaryContent"/>
>>
>> i see "politico" and "prueba" into Actualiza.action so the action
>> Actualiza works.
>>
>> Actualiza.java:
>>
>> package tads;
>> import java.util.*;
>>
>> import javax.servlet.http.HttpSession;
>> import com.opensymphony.xwork2.ActionSupport;
>> import org.apache.struts2.interceptor.SessionAware;
>> import com.opensymphony.xwork2.ActionContext;
>>
>>
>> @SuppressWarnings("serial")
>> public class Actualiza extends ActionSupport implements SessionAware {
>>   private String politico;
>>   private String prueba;
>>   private Map session;
>>     public String execute() throws Exception {
>>
>>       this.getSession().put("variable","pruebamil");
>>       return SUCCESS;
>>       }
>>   public String getPolitico() {
>>       return politico;
>>   }
>>
>>   public void setPolitico(String politico) {
>>       this.politico = politico;
>>   }
>>
>>   public String getPrueba() {
>>       return prueba;
>>   }
>>
>>   public void setPrueba(String prueba) {
>>       this.prueba = prueba;
>>   }
>>   public void setSession(Map session) {
>>       this.session = session;
>>     }
>>         public Map getSession() {
>>       return session;
>>     }
>> }
>>
>> in that situation. Actualiza.jsp doesn't show "variable" atribute from
>> session, using "<%= session.getAttribute( "variable" ) %>". It shows
>> null.
>>
>> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we
>> get access to the session).
>>
>> thanks in advance.
>>
> i've tried with
>
>       <%= session.getAttribute( "variable" ) %>
>
> and
>
>       <s:property value="#session.variable"></s:property>
>
> and surprise, both works. After closing and opening eclipse 3.4.0 works.
> I think this is a bad memory managing of eclipse. Does anybody knows
> something about this?
>
> --
> Sergio
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: problems with struts2 and session

Posted by Sergio <ki...@hotmail.com>.
Sergio escribió:
> Hi people,
>
> i'm a newbie to struts2. I'm having too many problems modifing session 
> parameters. I use <%= session.getAttribute( "variable" ) %> to gain 
> access to "variable" and that works when i modify "variable" into a 
> jsp page, but not inside a struts action.
>
> struts.xml:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>   "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>   "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> <struts>
>
>   <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>   <constant name="struts.devMode" value="true" />
>
> <package name="tads" namespace="/" extends="struts-default">
>
> <action name="HolaMundo" class="tads.HolaMundo">
> <result>/holaMundo.jsp</result>
> </action>
>
> <action name="Catalogo" class="tads.Catalogo">
>     <result  name="error">/ErrorCatalogo.jsp</result>
>     <result>/Catalogo.jsp</result>
>   </action>
>
> <action name="Actualiza" class="tads.Actualiza">
>     <result>/Actualiza.jsp</result>
>   </action>
>
>
>
> </package>
>
> </struts>
>
> extract from a jsp page, result from an ajax action working:
>
> <s:form id="form" >
>                 <s:textfield name="politico" label="politico"/><br>   
>                 <s:hidden name="prueba" value="escondido" />
>               </s:form>
>               <s:url id="actualiza" value="/Actualiza.action" />
>
> <sx:submit type="button" label="dale" href="%{actualiza}" 
> formId="form" align="center" targets="secondaryContent"/>
>
> i see "politico" and "prueba" into Actualiza.action so the action 
> Actualiza works.
>
> Actualiza.java:
>
> package tads;
> import java.util.*;
>
> import javax.servlet.http.HttpSession;
> import com.opensymphony.xwork2.ActionSupport;
> import org.apache.struts2.interceptor.SessionAware;
> import com.opensymphony.xwork2.ActionContext;
>
>
> @SuppressWarnings("serial")
> public class Actualiza extends ActionSupport implements SessionAware {
>   private String politico;
>   private String prueba;
>   private Map session;
>     public String execute() throws Exception {
>
>       this.getSession().put("variable","pruebamil");
>       return SUCCESS;
>       }
>   public String getPolitico() {
>       return politico;
>   }
>
>   public void setPolitico(String politico) {
>       this.politico = politico;
>   }
>
>   public String getPrueba() {
>       return prueba;
>   }
>
>   public void setPrueba(String prueba) {
>       this.prueba = prueba;
>   }
>   public void setSession(Map session) {
>       this.session = session;
>     }
>         public Map getSession() {
>       return session;
>     }
> }
>
> in that situation. Actualiza.jsp doesn't show "variable" atribute from 
> session, using "<%= session.getAttribute( "variable" ) %>". It shows 
> null.
>
> can anybody help me? I'm doing exactly what struts2 FAQ say (How do we 
> get access to the session).
>
> thanks in advance.
>
i've tried with

      <%= session.getAttribute( "variable" ) %>
     
and

      <s:property value="#session.variable"></s:property>

and surprise, both works. After closing and opening eclipse 3.4.0 works. 
I think this is a bad memory managing of eclipse. Does anybody knows 
something about this?

-- 
Sergio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org