struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frederik Minatchy <frederi...@yahoo.fr>
Subject Re: How to pass HTTPRequest between two JSP ?
Date Mon, 01 Mar 2010 10:36:38 GMT
Perhaps it because of me and the way I understand HTTPRequest.

Here is an other example :


in the class name :

fr.bnf.platon.bnf.actions.ConsultationEditeurDetailAction implementing ServletRequestAware
interface


when I am in the execute method I do :

 public String execute() throws Exception {
 ...
   request.setAttribute("isbnListe", isbnEditeurBeanById); // isbnEditeurBeanById is a map
...

    return SUCCESS;
}

and when I want to suppress element from the map stored in the request attribute

I do :

 public String supprimerIsbn()
{
   final Map<String, IsbnEditeurBean> allEditorIsbnToRemove =  (Map<String, IsbnEditeurBean>)
request.getAttribute("isbnListe"); // is null ... why ?
     ... 
    // remove selected elements 

   return "modification";
}

in my xml file I have :

...
  	<action name="editeur-detail" class="fr.bnf.platon.bnf.actions.ConsultationEditeurDetailAction"
>
        	<result name="input">/pages/bnf/consultationDemandes/detailEditeur.jsp</result>
        	<result name="success" type="dispatcher">
        		 <param name="location">/pages/bnf/consultationDemandes/detailEditeur.jsp</param>
        	</result>
        	<result name="modification" type="dispatcher">
        		<param name="location">/pages/bnf/consultationDemandes/detailEditeur.jsp</param>
     		</result>
        	<result name="supprimerISBN" type="dispatcher">
        		<param name="location">/pages/bnf/consultationDemandes/detailEditeur.jsp</param>
        	</result>           	
        </action>
...


and at least in the jsp :


I enter in the "supprimerIsbn" method with the submit button :
...
<s:submit method="supprimerIsbn" id="supprimerIsbn" type="submit" /> 
...


It's true... I can use Session... But after that I have to clean each elements I have set
in session


I am sure that the dispatch result is a solution... but perhaps I made a mistake in the web.xml
file.

For example why in my url I always have something like

http://localhost:8080/XXXXX/xxxxx.jsp and not http://localhost:8080/XXXXX/xxxxx.action?


Fred... Lost in struts2 world :(


--- En date de : Lun 1.3.10, Nils-Helge Garli Hegvik <nilsga@gmail.com> a écrit :

> De: Nils-Helge Garli Hegvik <nilsga@gmail.com>
> Objet: Re: How to pass HTTPRequest between two JSP ?
> À: "Struts Users Mailing List" <user@struts.apache.org>
> Date: Lundi 1 mars 2010, 9h50
> Either:
> 
> - Don't do a redirect, but a regular dispatch [1]
> - Store it in the session
> 
> Regards,
> 
> Nils-Helge Garli Hegvik
> 
> [1] - http://struts.apache.org/2.1.8.1/docs/dispatcher-result.html
> 
> 
> On Mon, Mar 1, 2010 at 10:40 AM, Frederik Minatchy <frederik78@yahoo.fr>
> wrote:
> >
> >
> > --- En date de : Lun 1.3.10, Alex Rodriguez Lopez
> <alopez@flordeutopia.pt>
> a écrit :
> >
> >> De: Alex Rodriguez Lopez <alopez@flordeutopia.pt>
> >> Objet: Re: How to pass HTTPRequest between two JSP
> ?
> >> À: "Struts Users Mailing List" <user@struts.apache.org>
> >> Date: Lundi 1 mars 2010, 9h21
> >> Em 28-02-2010 23:26, Frederik
> >> Minatchy escreveu:
> >> > Hello...
> >> >
> >> > Since a few days I am working with Struts 2.
> (2.1.6)
> >> > I am facing a big problem with HttpRequest
> and JSPs.
> >> >
> >> > Well... I have to forward a HTTPRequest from
> page1.jsp
> >> to page2.jsp
> >> >
> >> > So... How can I pass HTTPRequest attribute
> betwen 2
> >> pages?
> >> >
> >> > Here is a part my web.xml file :
> >> >
> >> > ...
> >> > <filter>
> >> >
> >> <filter-name>struts2</filter-name>
> >> >
> >>
> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
> >> >      </filter>
> >> >     <filter-mapping>
> >> >
> >> <filter-name>struts2</filter-name>
> >> >
> >> <url-pattern>/*</url-pattern>
> >> >     </filter-mapping>
> >> > ...
> >> >
> >> >
> >> > the struts.xml file :
> >> >
> >> > ...
> >> >
> >> > <action name="bnf-detail"
> >>
> class="fr.bnf.platon.bnf.actions.ConsultationBnfDetailAction">
> >> >
> >> <result
> >>
> name="success">/pages/bnf/administration/detailBnf.jsp</result>
> >> >         </action>
> >> >
> >> >
> >> >
> >> >         <action
> >> name="bnf-detail_modification"
> >>
> class="fr.bnf.platon.bnf.actions.ConsultationBnfDetailAction"
> >> method="modificationSubmit">
> >> >
> >> <result
> >>
> name="success">/pages/bnf/administration/detailBnf.jsp</result>
> >> >         </action>
> >> > ...
> >> >
> >> > and a part of the action java file (which
> >> implementents RequestAware):
> >> >
> >> >    public String execute() throws
> Exception
> >> >     {
> >> >        request.put("test", 58);
> >> >        return SUCCESS;
> >> >      }
> >> >
> >> >     public String
> >> modificationSubmit() throws TechniqueException,
> >> FonctionnelleException
> >> >     {
> >> >        request.get("test"); // is
> >> null
> >> >        editMode = true;
> >> >        return SUCCESS;
> >> >     }
> >> >
> >> >
> >> >
> >> > So... How can I pass the request attribute
> from on
> >> page to an other?
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >> I think you should be able to redirect with
> something like
> >> this:
> >> http://struts.apache.org/2.0.14/docs/redirect-action-result.html
> >>
> >> use return type redirect-action, work at request
> level
> >> redirecting
> >> requests, no jsps. I think request params are
> retained this
> >> way.
> >>
> >>
> >> Regards.
> >> Alex Lopez
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
> >
> > Thank you for your answer...
> >
> > But as I have to manage passwords I cannot pass values
> by using Request parameters (as they will appear in the
> url). I am forced to use Request Attributes. For the moment
> I am using SessionAware but it is not a good solution. Using
> Request attributes to store values seem to be a better way.
> (I remember that it was possible in strut 1.x wasn't it?)
> >
> >
> > I have read that with Dispatch result HTTPRequest was
> "kept" on the server and was not lost... I am trying to
> implement things as it is written in documentation but it
> fails...
> >
> > I appreciate your help...
> >
> > Fred
> >
> >
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > 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
> 
> 


      

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


Mime
View raw message