You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mete Kural <me...@yahoo.com> on 2002/06/24 20:34:10 UTC

Sub-apps Question - Urgent Help Needed

Hello,

I've been trying to get a hold on how to effectively
use these sub-apps but I'm confused about how to
switch between sub-apps still after reading the few
messages on the topic already in the archives.

I have two sub-apps in my web-app: default and
/catalog.

I added the switch action to my action-mappings in the
/catalog sub-app config file i.e.
struts-config-catalog.xml

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

If I call the /switch action in the /catalog sub-app
it should switch to the default sub-app if the correct
parameters are given.

But when I type this in the address bar of the web
browser:

http://localhost/catalog/switch.do?prefix=&page=/

, I get the directory listing for /catalog the first
line starting with "Directory Listing For /catalog/"
and then listing all the jsp files in my /catalog
directory.

Shouldn't it take me to the index page for the default
sup-app, i.e. /index.html ?

I set up the switch action in the default sub-app's
config file as well. When I type this in the address
bar of the browser:
http://localhost/switch.do?page=/&prefix=
It takes me to the index page for the default sub-app
as it should. But why not when I call the switch
action from the /catalog sub-app?

Are my parameters incorrect? I'm giving a zero-length
string prefix for the default sub-app and the URI "/"
for the index page. What do you think I'm doing wrong
here? 

Peace,
Mete


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Sub-apps Question - Urgent Help Needed

Posted by Mete Kural <me...@yahoo.com>.
Thanks for the tip Craig. It worked after putting
these lines in the Action class:

// switch to the default sub-application for logon
RequestUtils.selectApplication("", request,
servlet.getServletConfig().getServletContext());
          return (mapping.findForward("logon"));

Although still mapping.findForward("logon") does not
return the "logon" forward for the default
application, but rather the one for the /catalog
sub-application, even if with selectApplication() I
switched from /catalog to default. Because of this, I
had to add an additional forward "logon" in the config
file for the /catalog sub-app that just points to
"/../logon.jsp". It's no problem since it works, but I
was just wondering about something. You said:

> This should cause any subsequent operations
> (including
> interpretation of things like
> mapping.findForward()), to be interpreted
> against the new sub-app instead of the old one

mapping.findForward() still behaves as if it's in the
old sub-app in my case. Is there something wrong with
the way I call selectApplication?

Thanks,
Mete


--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> I think it was added subsequent to the release of
> 1.1-beta-1, but I know
> that in the current nightly builds you should be
> able to call
> RequestUtils.selectApplication() yourself, during
> the execution of an
> Action.  This should cause any subsequent operations
> (including
> interpretation of things like
> mapping.findForward()), to be interpreted
> against the new sub-app instead of the old one.
> 
> Craig
> 
> 
> 
> 
> On Tue, 25 Jun 2002, Mete Kural wrote:
> 
> > Date: Tue, 25 Jun 2002 10:49:51 -0700 (PDT)
> > From: Mete Kural <me...@yahoo.com>
> > Reply-To: Struts Users Mailing List
> <st...@jakarta.apache.org>
> > To: Struts Users Mailing List
> <st...@jakarta.apache.org>
> > Cc: rleland@apache.org
> > Subject: Re: Sub-apps Question - Urgent Help
> Needed
> >
> > Hi Rob,
> >
> > > I haven't used the SwitchAction yet but I have
> been
> > > using sub-apps for about
> > > 2 Months, so...
> >
> > Thank God there is another person on this list
> that
> > uses sub-apps. I think they are pretty cool and
> all
> > that but I guess because they're new people aren't
> > used to them yet.
> >
> > > Doesn't your application have a context ?
> > >
> > > How about
> > >
> > >
> >
>
http://localhost/application-context/catalog/switch.do?prefix=&page=/
> >
> > The webapp is a /ROOT app so the application
> context
> > is root. I'm sorry not not make that clear.
> >
> > My original intention was actually not to use
> > SwitchAction. In my case, what I'm doing is:
> >
> > 1) CheckoutAction in the /catalog sub-app, i.e.
> > "/catalog/checkout.do" is called from a catalog
> page
> > shoppingCart.jsp, i.e. /catalog/shoppingCart.jsp.
> >
> > 2) CheckoutAction does some processing, finds out
> that
> > the user is not logged in and decides that it
> should
> > forward the request to a page "logon.jsp" in the
> > default sub-app, i.e. "/logon.jsp" (This is
> because
> > logon operations are handled in the defualt
> sub-app
> > and not in the /catalog sub-app).
> >
> > 3) CheckoutAction returns the forward with the
> logical
> > name "logon".
> >
> > I was confused at this point. So how will the
> > CheckoutAction find the forward "logon" that is in
> the
> > default sub-app, not in the /catalog sub-app? I
> > couldn't figure this out, so I decided to create a
> new
> > forward named "logon" in the /catalog sub-app
> config
> > file, i.e. struts-config-catalog.xml.
> >
> > This was the new forward in
> struts-config-catalog.xml:
> >
> > <forward name="logon"
> >   path="/switch.do? prefix=&page=/logon.do" />
> >
> > I didn't like this because it seems like an
> indirect
> > way of switching between sub-apps in this specific
> > case, while there has to be a simpler more direct
> way
> > to forward to the /logon.jsp from the
> > /catalog/checkout.do action.
> >
> > Well this SwitchAction idea didn't work anyways,
> so if
> > you have any suggestion at all at how you think I
> can
> > do this seemingly simple task of forwarding to a
> jsp
> > file of another sub-app, I would greatly
> appreciate
> > your help.
> >
> > Thank you,
> > Mete Kural
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! - Official partner of 2002 FIFA World Cup
> > http://fifaworldcup.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Sub-apps Question - Urgent Help Needed

Posted by "Craig R. McClanahan" <cr...@apache.org>.
I think it was added subsequent to the release of 1.1-beta-1, but I know
that in the current nightly builds you should be able to call
RequestUtils.selectApplication() yourself, during the execution of an
Action.  This should cause any subsequent operations (including
interpretation of things like mapping.findForward()), to be interpreted
against the new sub-app instead of the old one.

Craig




On Tue, 25 Jun 2002, Mete Kural wrote:

> Date: Tue, 25 Jun 2002 10:49:51 -0700 (PDT)
> From: Mete Kural <me...@yahoo.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Cc: rleland@apache.org
> Subject: Re: Sub-apps Question - Urgent Help Needed
>
> Hi Rob,
>
> > I haven't used the SwitchAction yet but I have been
> > using sub-apps for about
> > 2 Months, so...
>
> Thank God there is another person on this list that
> uses sub-apps. I think they are pretty cool and all
> that but I guess because they're new people aren't
> used to them yet.
>
> > Doesn't your application have a context ?
> >
> > How about
> >
> >
> http://localhost/application-context/catalog/switch.do?prefix=&page=/
>
> The webapp is a /ROOT app so the application context
> is root. I'm sorry not not make that clear.
>
> My original intention was actually not to use
> SwitchAction. In my case, what I'm doing is:
>
> 1) CheckoutAction in the /catalog sub-app, i.e.
> "/catalog/checkout.do" is called from a catalog page
> shoppingCart.jsp, i.e. /catalog/shoppingCart.jsp.
>
> 2) CheckoutAction does some processing, finds out that
> the user is not logged in and decides that it should
> forward the request to a page "logon.jsp" in the
> default sub-app, i.e. "/logon.jsp" (This is because
> logon operations are handled in the defualt sub-app
> and not in the /catalog sub-app).
>
> 3) CheckoutAction returns the forward with the logical
> name "logon".
>
> I was confused at this point. So how will the
> CheckoutAction find the forward "logon" that is in the
> default sub-app, not in the /catalog sub-app? I
> couldn't figure this out, so I decided to create a new
> forward named "logon" in the /catalog sub-app config
> file, i.e. struts-config-catalog.xml.
>
> This was the new forward in struts-config-catalog.xml:
>
> <forward name="logon"
>   path="/switch.do? prefix=&page=/logon.do" />
>
> I didn't like this because it seems like an indirect
> way of switching between sub-apps in this specific
> case, while there has to be a simpler more direct way
> to forward to the /logon.jsp from the
> /catalog/checkout.do action.
>
> Well this SwitchAction idea didn't work anyways, so if
> you have any suggestion at all at how you think I can
> do this seemingly simple task of forwarding to a jsp
> file of another sub-app, I would greatly appreciate
> your help.
>
> Thank you,
> Mete Kural
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Sub-apps Question - Urgent Help Needed

Posted by Mete Kural <me...@yahoo.com>.
Hi Rob,

> I haven't used the SwitchAction yet but I have been
> using sub-apps for about
> 2 Months, so...

Thank God there is another person on this list that
uses sub-apps. I think they are pretty cool and all
that but I guess because they're new people aren't
used to them yet.

> Doesn't your application have a context ?
> 
> How about
> 
>
http://localhost/application-context/catalog/switch.do?prefix=&page=/

The webapp is a /ROOT app so the application context
is root. I'm sorry not not make that clear.

My original intention was actually not to use
SwitchAction. In my case, what I'm doing is:

1) CheckoutAction in the /catalog sub-app, i.e.
"/catalog/checkout.do" is called from a catalog page
shoppingCart.jsp, i.e. /catalog/shoppingCart.jsp.

2) CheckoutAction does some processing, finds out that
the user is not logged in and decides that it should
forward the request to a page "logon.jsp" in the
default sub-app, i.e. "/logon.jsp" (This is because
logon operations are handled in the defualt sub-app
and not in the /catalog sub-app).

3) CheckoutAction returns the forward with the logical
name "logon".

I was confused at this point. So how will the
CheckoutAction find the forward "logon" that is in the
default sub-app, not in the /catalog sub-app? I
couldn't figure this out, so I decided to create a new
forward named "logon" in the /catalog sub-app config
file, i.e. struts-config-catalog.xml.

This was the new forward in struts-config-catalog.xml:

<forward name="logon" 
  path="/switch.do? prefix=&page=/logon.do" /> 

I didn't like this because it seems like an indirect
way of switching between sub-apps in this specific
case, while there has to be a simpler more direct way
to forward to the /logon.jsp from the
/catalog/checkout.do action.

Well this SwitchAction idea didn't work anyways, so if
you have any suggestion at all at how you think I can
do this seemingly simple task of forwarding to a jsp
file of another sub-app, I would greatly appreciate
your help.

Thank you,
Mete Kural




__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Sub-apps Question - Urgent Help Needed

Posted by Rob Leland <rl...@apache.org>.
Mete Kural wrote:

>
>
>http://localhost/catalog/switch.do?prefix=&page=/
>
I haven't used the SwitchAction yet but I have been using sub-apps for about
2 Months, so...

Doesn't your application have a context ?

How about

http://localhost/application-context/catalog/switch.do?prefix=&page=/

?
-Rob

>
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>