You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pooja Kaur <po...@gmail.com> on 2007/08/13 09:10:39 UTC

switch action - doubt

Hi,
I have 2 war files added to an EAR. Both of them have a different context
root. Eg. Module A has test1 as the context root and Module B has test2
I did the following in the struts-config of Module A which is the default
module:
1. Added an action

<action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>

2. The link to switch the module has the URL eg.

toModule.do?prefix=/test2
&page=/forwardToTrainingDB.do

When I click on the link with the above url , i get 400 (Bad Request) Error
message.

The mapping for forwardToTrainingDB.do is present in the struts-config xml
file of test2 module.

Please help me how to resolve this problem.

Thanks

Re: switch action - doubt

Posted by Pooja Kaur <po...@gmail.com>.
Thanks all for replying.
Here is my actual problem statement:
I have one web project named eg. "Training"
and 2nd project named eg. "Test".
The login to application is through the "Test" Project. I want a link in the
Test project which points to the "Training" project and this 'Training"
project should be able to get the user details from the session.
What I have done is:
I created a WAR file for this new Training project and put this war file in
the EAR file of the "Test" project. In this application.xml file of "Test"
project, now there are 2 wars present with different context roots.
I tried using SwitchAction to switch between these war files and have
mentioned the problems i am facing.
Is there a better and feasible way to implement this scenario. I am running
my appl through WSAD.


On 8/13/07, Nagraj Rao <na...@sigmainfo.net> wrote:
>
>
> Are you submitting any request params or simply redirecting it to the new
> URL??
> I hope simple re-directing should work. For that you can specify
> redirect=true as an attribute in the forward tag.
>
> Sorry to be replying directly. For some reason my mails are  not reaching
> the struts group.
>
> N
>
> -----Original Message-----
> From: Pooja Kaur [mailto:poojakaur@gmail.com]
> Sent: Monday, August 13, 2007 2:44 PM
> To: user@struts.apache.org
> Subject: Re: switch action - doubt
>
> Please anyone reply....
>
>
>
> On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
> >
> > Hi,
> > I have 2 war files added to an EAR. Both of them have a different
> context
> > root. Eg. Module A has test1 as the context root and Module B has test2
> > I did the following in the struts-config of Module A which is the
> default
> > module:
> > 1. Added an action
> >
> > <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
> >
> > 2. The link to switch the module has the URL eg.
> >
> > toModule.do?prefix=/test2
> > &page=/forwardToTrainingDB.do
> >
> > When I click on the link with the above url , i get 400 (Bad Request)
> > Error message.
> >
> > The mapping for forwardToTrainingDB.do is present in the struts-config
> xml
> > file of test2 module.
> >
> > Please help me how to resolve this problem.
> >
> > Thanks
> >
> >
> >
>
>

RE: switch action - doubt

Posted by Nagraj Rao <na...@sigmainfo.net>.
Are you submitting any request params or simply redirecting it to the new
URL??
I hope simple re-directing should work. For that you can specify
redirect=true as an attribute in the forward tag.

-----Original Message-----
From: Pooja Kaur [mailto:poojakaur@gmail.com] 
Sent: Monday, August 13, 2007 2:44 PM
To: user@struts.apache.org
Subject: Re: switch action - doubt

Please anyone reply....



On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
>
> Hi,
> I have 2 war files added to an EAR. Both of them have a different context
> root. Eg. Module A has test1 as the context root and Module B has test2
> I did the following in the struts-config of Module A which is the default
> module:
> 1. Added an action
>
> <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
>
> 2. The link to switch the module has the URL eg.
>
> toModule.do?prefix=/test2
> &page=/forwardToTrainingDB.do
>
> When I click on the link with the above url , i get 400 (Bad Request)
> Error message.
>
> The mapping for forwardToTrainingDB.do is present in the struts-config xml
> file of test2 module.
>
> Please help me how to resolve this problem.
>
> Thanks
>
>
>


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


Re: switch action - doubt

Posted by Pooja Kaur <po...@gmail.com>.
Please anyone reply....



On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
>
> Hi,
> I have 2 war files added to an EAR. Both of them have a different context
> root. Eg. Module A has test1 as the context root and Module B has test2
> I did the following in the struts-config of Module A which is the default
> module:
> 1. Added an action
>
> <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
>
> 2. The link to switch the module has the URL eg.
>
> toModule.do?prefix=/test2
> &page=/forwardToTrainingDB.do
>
> When I click on the link with the above url , i get 400 (Bad Request)
> Error message.
>
> The mapping for forwardToTrainingDB.do is present in the struts-config xml
> file of test2 module.
>
> Please help me how to resolve this problem.
>
> Thanks
>
>
>

Re: switch action - doubt

Posted by Pooja Kaur <po...@gmail.com>.
The application.xml file of the EAR has two different wars with different
context roots specified for them? What else should I update to imply to the
server that the context root has changed?
I tried by adding a global forward:

<forward name="test2" contextRelative="true"
path="/test2/forwardToTrainingDB.do"
redirect="true"/>

and put the url as test2. But , when I run the appl, the complete url formed
is:

http://localhost:9080/test1/test2

whereas I want it to be http://localhost:9080/test2/forwardToTrainingDB.do

What should i do?



On 8/13/07, Paul Benedict <pb...@apache.org> wrote:
>
> SwitchAction does not switch between applications. It switches between
> Struts modules within one application. What you want to do is include the
> context root in your paths. There's an attribute for that. I believe it's
> contextRelative=true
>
> Paul
>
> On 8/13/07, ANIMESH SAXENA <an...@gmail.com> wrote:
> >
> > Could you please mention which struts version??
> >
> > On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
> > >
> > > Hi,
> > > I have 2 war files added to an EAR. Both of them have a different
> > context
> > > root. Eg. Module A has test1 as the context root and Module B has
> test2
> > > I did the following in the struts-config of Module A which is the
> > default
> > > module:
> > > 1. Added an action
> > >
> > > <action path="/toModule" type="org.apache.struts.actions.SwitchAction
> "/>
> > >
> > > 2. The link to switch the module has the URL eg.
> > >
> > > toModule.do?prefix=/test2
> > > &page=/forwardToTrainingDB.do
> > >
> > > When I click on the link with the above url , i get 400 (Bad Request)
> > > Error
> > > message.
> > >
> > > The mapping for forwardToTrainingDB.do is present in the struts-config
> > xml
> > > file of test2 module.
> > >
> > > Please help me how to resolve this problem.
> > >
> > > Thanks
> > >
> >
> >
> >
> > --
> > Animesh Saxena
> >
> >
> > http://inlovewithlinux.blogspot.com
> >
>

Re: switch action - doubt

Posted by Paul Benedict <pb...@apache.org>.
SwitchAction does not switch between applications. It switches between
Struts modules within one application. What you want to do is include the
context root in your paths. There's an attribute for that. I believe it's
contextRelative=true

Paul

On 8/13/07, ANIMESH SAXENA <an...@gmail.com> wrote:
>
> Could you please mention which struts version??
>
> On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
> >
> > Hi,
> > I have 2 war files added to an EAR. Both of them have a different
> context
> > root. Eg. Module A has test1 as the context root and Module B has test2
> > I did the following in the struts-config of Module A which is the
> default
> > module:
> > 1. Added an action
> >
> > <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
> >
> > 2. The link to switch the module has the URL eg.
> >
> > toModule.do?prefix=/test2
> > &page=/forwardToTrainingDB.do
> >
> > When I click on the link with the above url , i get 400 (Bad Request)
> > Error
> > message.
> >
> > The mapping for forwardToTrainingDB.do is present in the struts-config
> xml
> > file of test2 module.
> >
> > Please help me how to resolve this problem.
> >
> > Thanks
> >
>
>
>
> --
> Animesh Saxena
>
>
> http://inlovewithlinux.blogspot.com
>

Re: switch action - doubt

Posted by Pooja Kaur <po...@gmail.com>.
Struts Version is : 1.1
One more strange thing that is happening is:

If i put the url as :
http://localhost:9080/spmod/toModule.do?prefix=&page=/forwardToTrainingDB.doand
debug, I reach the ActionClass having 'forwardToTrainingDB' as the
action mapping, and then I get 404 error.
It seems like it is not recognising the Module B's context root.

On 8/13/07, ANIMESH SAXENA <an...@gmail.com> wrote:
>
> Could you please mention which struts version??
>
> On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
> >
> > Hi,
> > I have 2 war files added to an EAR. Both of them have a different
> context
> > root. Eg. Module A has test1 as the context root and Module B has test2
> > I did the following in the struts-config of Module A which is the
> default
> > module:
> > 1. Added an action
> >
> > <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
> >
> > 2. The link to switch the module has the URL eg.
> >
> > toModule.do?prefix=/test2
> > &page=/forwardToTrainingDB.do
> >
> > When I click on the link with the above url , i get 400 (Bad Request)
> > Error
> > message.
> >
> > The mapping for forwardToTrainingDB.do is present in the struts-config
> xml
> > file of test2 module.
> >
> > Please help me how to resolve this problem.
> >
> > Thanks
> >
>
>
>
> --
> Animesh Saxena
>
>
> http://inlovewithlinux.blogspot.com
>

Re: switch action - doubt

Posted by ANIMESH SAXENA <an...@gmail.com>.
Could you please mention which struts version??

On 8/13/07, Pooja Kaur <po...@gmail.com> wrote:
>
> Hi,
> I have 2 war files added to an EAR. Both of them have a different context
> root. Eg. Module A has test1 as the context root and Module B has test2
> I did the following in the struts-config of Module A which is the default
> module:
> 1. Added an action
>
> <action path="/toModule" type="org.apache.struts.actions.SwitchAction"/>
>
> 2. The link to switch the module has the URL eg.
>
> toModule.do?prefix=/test2
> &page=/forwardToTrainingDB.do
>
> When I click on the link with the above url , i get 400 (Bad Request)
> Error
> message.
>
> The mapping for forwardToTrainingDB.do is present in the struts-config xml
> file of test2 module.
>
> Please help me how to resolve this problem.
>
> Thanks
>



-- 
Animesh Saxena


http://inlovewithlinux.blogspot.com