You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Olivier Libouban <li...@bea.com> on 2002/08/07 17:59:54 UTC
Do sub-apps work?
I've configured a simplistic sub-app, using
the web.xml init-param:
------------------------ web.xml ----------------------
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-main-config.xml</param-value>
</init-param>
<init-param>
<param-name>config/sub-app</param-name>
<param-value>/WEB-INF/struts-question-config.xml</param-value>
</init-param>
---------------------------------------------------------
In struts-question-config.xml, (for the sub-app), I have an action:
---------------- struts-question-config.xml -------------
<!-- Computation -->
<!-- The same form is used for both the subtraction and the
computation -->
<action path="/sub-app/operate"
type="org.apache.struts.webapp.example.ComputeDispatchAction"
parameter="method"
name="subtractionForm"
scope="request"
validate="true"
input="/sub-app/operation.jsp">
<forward name="success" path="/sub-app/operation.jsp"
redirect="false" />
</action>
---------------------------------------------------------
Finally, under 'sub-app/operation.jsp', a form is used to call
the action 'sub-app/operate'.
------------ operation.jsp --------------------------------
[...]
<html:form action="/sub-app/operate.do">
[...]
-----------------------------------------------------------
Going to 'sub-app/operation.jsp' URL, I get
this message:
------------ Browser -----------------------------------------
[ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
for action /sub-app/operate'
-----------------------------------------------------------------------------------------------
In 4.1.7b1, the 'init' method of ActionServlet was not being called.
(That's were the parsing for the config seems to happen). I switched
over to 4.0.4, and I do see:
------------------- stdout for Tomcat 4.0.4. ----------------------
[INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
[INFO] ActionServlet - -Initializing application path '' configuration
from '/WE
B-INF/struts-main-config.xml'
[INFO] MemoryDatabasePlugIn - -Initializing memory database plug in from
'/WEB-I
NF/database.xml'
[INFO] ActionServlet - -Initializing application path '/sub-app'
configuration f
rom '/WEB-INF/struts-question-config.xml'
-------------------------------------------------------------------
which seems to indicate the sub-app web.xml entry did get parsed,
What am I missing?
Thanks,
Olivier Libouban
Re: Do sub-apps work?
Posted by Olivier Libouban <li...@bea.com>.
Craig,
I had tried that too. It did not work.
Is there an example you could point me
to that does work? I have not seen one
in the src/example..., not in contrib.
Thanks,
Olivier.
Craig R. McClanahan wrote:
>
>On Wed, 7 Aug 2002, Olivier Libouban wrote:
>
>>Date: Wed, 07 Aug 2002 10:58:55 -0600
>>From: Olivier Libouban <li...@bea.com>
>>Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
>>To: Struts Users Mailing List <st...@jakarta.apache.org>
>>Subject: Re: Do sub-apps work?
>>
>>Craig,
>>
>> Thanks for your answer.
>>
>> I'm not sure which part of the set up you are
>> referring to. The
>>
>><html:form action="/sub-app/operate.do">
>> in the operation.jsp below?
>>
>
>You should not need to specify the subapp name here. All action paths are
>supposed to be automatically prefixed, so your action definition should
>say:
>
> <action path="/operate" ...>
>
>and your form should say
>
> <html:form action="/operate" ...>
>
>The goal is that a particular sub-app module should work either as the
>default sub-app, or with a prefix, with zero changes. To make that
>happen, Struts will prefix the paths as needed if you obey all the rules.
>
>> Another part of the set up described below?
>>
>> Is the FormTag hack un-necessary?
>>
>
>It worked for me last time I tried, using the technique described above.
>I'll check again.
>
>> Thanks again,
>>
>>Olivier Libouban
>>
>
>Craig
>
>
>>
>>
>>
>>
>>Craig R. McClanahan wrote:
>>
>>>On Wed, 7 Aug 2002, Olivier Libouban wrote:
>>>
>>>>Date: Wed, 07 Aug 2002 10:41:14 -0600
>>>>From: Olivier Libouban <li...@bea.com>
>>>>Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
>>>>To: Struts Users Mailing List <st...@jakarta.apache.org>
>>>>Subject: Re: Do sub-apps work?
>>>>
>>>>I guess they don't.
>>>>
>>>Are you obeying the restriction that *all* requests must flow through the
>>>controller servlet? In other words, you cannot have any hyperlinks that
>>>point directly at a JSP page. If you do, that page will always assume it
>>>is part of the root sub-app instead of the correct one.
>>>
>>>This is a restriction due to the fact that Struts cannot use Filters yet
>>>-- we are still requiring only the Servlet 2.2 / JSP 1.1 platform. It
>>>will go away in a future version of Struts, where we can configure a
>>>filter that does the sub-app assignment for all requests, no matter what
>>>the URL is.
>>>
>>>Craig
>>>
>>>>This is what I figured out:
>>>>The FormTag does not look at
>>>>sub-app configuration, only the main one.
>>>>I put the following code in it, to verify that was
>>>>the case:
>>>>---------------- **HACKED** FormTag.java, lookup method-------
>>>> protected void lookup() throws JspException {
>>>>
>>>> // Look up the application configuration information we need
>>>> appConfig = (ApplicationConfig)
>>>> pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
>>>>
>>>> System.out.println("FormTag: Action.APPLICATION_KEY = '" +
>>>>Action.APPLICATION_KEY);
>>>> if (appConfig == null)
>>>> {
>>>> // GET THE PREFIX SOMEHOW THIS IS A HACK FOR ME ONLY. Olivier.!!
>>>> String prefix = "/sub-app";
>>>> appConfig = (ApplicationConfig)
>>>>
>>>>pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY +
>>>>prefix);
>>>> System.out.println("FormTag: hack for = '" +
>>>>Action.APPLICATION_KEY + prefix);
>>>> }
>>>>-----------------------------------------------------------------------------
>>>>You will notive the "if (appConfig == null), get the appConfig using a
>>>>PREFIX,
>>>>(here hard-coded for my purpose.
>>>>
>>>>At that point, I modified the operate command to indicate /operation.jsp
>>>>instead of /sub-app/operation in 'struts-question-config.xml', since the
>>>>sub-app
>>>>portion gets added at run-time. It now ... kind'o works. I have not
>>>>looked at
>>>>other tags, but I suspect the same there.
>>>>
>>>>Olivier Libouban
>>>>
>>>>
>>>>Olivier Libouban wrote:
>>>>
>>>>> I've configured a simplistic sub-app, using
>>>>>the web.xml init-param:
>>>>>------------------------ web.xml ----------------------
>>>>><servlet>
>>>>> <servlet-name>action</servlet-name>
>>>>> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>>>>> <init-param>
>>>>> <param-name>config</param-name>
>>>>> <param-value>/WEB-INF/struts-main-config.xml</param-value>
>>>>> </init-param>
>>>>> <init-param>
>>>>> <param-name>config/sub-app</param-name>
>>>>> <param-value>/WEB-INF/struts-question-config.xml</param-value>
>>>>> </init-param>
>>>>>---------------------------------------------------------
>>>>>
>>>>>In struts-question-config.xml, (for the sub-app), I have an action:
>>>>>---------------- struts-question-config.xml -------------
>>>>> <!-- Computation -->
>>>>> <!-- The same form is used for both the subtraction and the
>>>>>computation -->
>>>>> <action path="/sub-app/operate"
>>>>> type="org.apache.struts.webapp.example.ComputeDispatchAction"
>>>>> parameter="method"
>>>>> name="subtractionForm"
>>>>> scope="request"
>>>>> validate="true"
>>>>> input="/sub-app/operation.jsp">
>>>>> <forward name="success" path="/sub-app/operation.jsp"
>>>>>redirect="false" />
>>>>> </action>
>>>>>---------------------------------------------------------
>>>>>
>>>>>
>>>>>Finally, under 'sub-app/operation.jsp', a form is used to call
>>>>>the action 'sub-app/operate'.
>>>>>------------ operation.jsp --------------------------------
>>>>>[...]
>>>>><html:form action="/sub-app/operate.do">
>>>>>[...]
>>>>>-----------------------------------------------------------
>>>>>
>>>>>
>>>>>Going to 'sub-app/operation.jsp' URL, I get
>>>>>this message:
>>>>>------------ Browser -----------------------------------------
>>>>>[ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
>>>>>for action /sub-app/operate'
>>>>>-----------------------------------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>>In 4.1.7b1, the 'init' method of ActionServlet was not being called.
>>>>>(That's were the parsing for the config seems to happen). I switched
>>>>>over to 4.0.4, and I do see:
>>>>>------------------- stdout for Tomcat 4.0.4. ----------------------
>>>>>[INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
>>>>>[INFO] ActionServlet - -Initializing application path '' configuration
>>>>>
>>>>>from '/WE
>>>>
>>>>>B-INF/struts-main-config.xml'
>>>>>[INFO] MemoryDatabasePlugIn - -Initializing memory database plug in
>>>>>
>>>>>from '/WEB-I
>>>>
>>>>>NF/database.xml'
>>>>>[INFO] ActionServlet - -Initializing application path '/sub-app'
>>>>>configuration f
>>>>>rom '/WEB-INF/struts-question-config.xml'
>>>>>-------------------------------------------------------------------
>>>>>
>>>>>which seems to indicate the sub-app web.xml entry did get parsed,
>>>>>
>>>>>
>>>>>What am I missing?
>>>>>
>>>>>Thanks,
>>>>>
>>>>>Olivier Libouban
>>>>>
>>>>>
>>>>>
>>>
>>>--
>>>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: Do sub-apps work?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 7 Aug 2002, Olivier Libouban wrote:
> Date: Wed, 07 Aug 2002 10:58:55 -0600
> From: Olivier Libouban <li...@bea.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Do sub-apps work?
>
> Craig,
>
> Thanks for your answer.
>
> I'm not sure which part of the set up you are
> referring to. The
>
> <html:form action="/sub-app/operate.do">
> in the operation.jsp below?
You should not need to specify the subapp name here. All action paths are
supposed to be automatically prefixed, so your action definition should
say:
<action path="/operate" ...>
and your form should say
<html:form action="/operate" ...>
The goal is that a particular sub-app module should work either as the
default sub-app, or with a prefix, with zero changes. To make that
happen, Struts will prefix the paths as needed if you obey all the rules.
>
> Another part of the set up described below?
>
> Is the FormTag hack un-necessary?
>
It worked for me last time I tried, using the technique described above.
I'll check again.
> Thanks again,
>
> Olivier Libouban
>
Craig
>
>
>
>
>
> Craig R. McClanahan wrote:
>
> >
> >On Wed, 7 Aug 2002, Olivier Libouban wrote:
> >
> >>Date: Wed, 07 Aug 2002 10:41:14 -0600
> >>From: Olivier Libouban <li...@bea.com>
> >>Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> >>To: Struts Users Mailing List <st...@jakarta.apache.org>
> >>Subject: Re: Do sub-apps work?
> >>
> >>I guess they don't.
> >>
> >
> >Are you obeying the restriction that *all* requests must flow through the
> >controller servlet? In other words, you cannot have any hyperlinks that
> >point directly at a JSP page. If you do, that page will always assume it
> >is part of the root sub-app instead of the correct one.
> >
> >This is a restriction due to the fact that Struts cannot use Filters yet
> >-- we are still requiring only the Servlet 2.2 / JSP 1.1 platform. It
> >will go away in a future version of Struts, where we can configure a
> >filter that does the sub-app assignment for all requests, no matter what
> >the URL is.
> >
> >Craig
> >
> >>This is what I figured out:
> >>The FormTag does not look at
> >>sub-app configuration, only the main one.
> >>I put the following code in it, to verify that was
> >>the case:
> >>---------------- **HACKED** FormTag.java, lookup method-------
> >> protected void lookup() throws JspException {
> >>
> >> // Look up the application configuration information we need
> >> appConfig = (ApplicationConfig)
> >> pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
> >>
> >> System.out.println("FormTag: Action.APPLICATION_KEY = '" +
> >>Action.APPLICATION_KEY);
> >> if (appConfig == null)
> >> {
> >> // GET THE PREFIX SOMEHOW THIS IS A HACK FOR ME ONLY. Olivier.!!
> >> String prefix = "/sub-app";
> >> appConfig = (ApplicationConfig)
> >>
> >>pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY +
> >>prefix);
> >> System.out.println("FormTag: hack for = '" +
> >>Action.APPLICATION_KEY + prefix);
> >> }
> >>-----------------------------------------------------------------------------
> >>You will notive the "if (appConfig == null), get the appConfig using a
> >>PREFIX,
> >>(here hard-coded for my purpose.
> >>
> >>At that point, I modified the operate command to indicate /operation.jsp
> >>instead of /sub-app/operation in 'struts-question-config.xml', since the
> >>sub-app
> >>portion gets added at run-time. It now ... kind'o works. I have not
> >>looked at
> >>other tags, but I suspect the same there.
> >>
> >>Olivier Libouban
> >>
> >>
> >>Olivier Libouban wrote:
> >>
> >>> I've configured a simplistic sub-app, using
> >>>the web.xml init-param:
> >>>------------------------ web.xml ----------------------
> >>> <servlet>
> >>> <servlet-name>action</servlet-name>
> >>> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> >>> <init-param>
> >>> <param-name>config</param-name>
> >>> <param-value>/WEB-INF/struts-main-config.xml</param-value>
> >>> </init-param>
> >>> <init-param>
> >>> <param-name>config/sub-app</param-name>
> >>> <param-value>/WEB-INF/struts-question-config.xml</param-value>
> >>> </init-param>
> >>>---------------------------------------------------------
> >>>
> >>>In struts-question-config.xml, (for the sub-app), I have an action:
> >>>---------------- struts-question-config.xml -------------
> >>> <!-- Computation -->
> >>> <!-- The same form is used for both the subtraction and the
> >>>computation -->
> >>> <action path="/sub-app/operate"
> >>> type="org.apache.struts.webapp.example.ComputeDispatchAction"
> >>> parameter="method"
> >>> name="subtractionForm"
> >>> scope="request"
> >>> validate="true"
> >>> input="/sub-app/operation.jsp">
> >>> <forward name="success" path="/sub-app/operation.jsp"
> >>>redirect="false" />
> >>> </action>
> >>>---------------------------------------------------------
> >>>
> >>>
> >>>Finally, under 'sub-app/operation.jsp', a form is used to call
> >>>the action 'sub-app/operate'.
> >>>------------ operation.jsp --------------------------------
> >>>[...]
> >>><html:form action="/sub-app/operate.do">
> >>>[...]
> >>>-----------------------------------------------------------
> >>>
> >>>
> >>>Going to 'sub-app/operation.jsp' URL, I get
> >>>this message:
> >>>------------ Browser -----------------------------------------
> >>>[ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
> >>>for action /sub-app/operate'
> >>>-----------------------------------------------------------------------------------------------
> >>>
> >>>
> >>>
> >>>In 4.1.7b1, the 'init' method of ActionServlet was not being called.
> >>>(That's were the parsing for the config seems to happen). I switched
> >>>over to 4.0.4, and I do see:
> >>>------------------- stdout for Tomcat 4.0.4. ----------------------
> >>>[INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
> >>>[INFO] ActionServlet - -Initializing application path '' configuration
> >>>from '/WE
> >>>B-INF/struts-main-config.xml'
> >>>[INFO] MemoryDatabasePlugIn - -Initializing memory database plug in
> >>>from '/WEB-I
> >>>NF/database.xml'
> >>>[INFO] ActionServlet - -Initializing application path '/sub-app'
> >>>configuration f
> >>>rom '/WEB-INF/struts-question-config.xml'
> >>>-------------------------------------------------------------------
> >>>
> >>>which seems to indicate the sub-app web.xml entry did get parsed,
> >>>
> >>>
> >>>What am I missing?
> >>>
> >>>Thanks,
> >>>
> >>>Olivier Libouban
> >>>
> >>>
> >>>
> >>
> >
> >
> >--
> >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: Do sub-apps work?
Posted by Olivier Libouban <li...@bea.com>.
Craig,
Thanks for your answer.
I'm not sure which part of the set up you are
referring to. The
<html:form action="/sub-app/operate.do">
in the operation.jsp below?
Another part of the set up described below?
Is the FormTag hack un-necessary?
Thanks again,
Olivier Libouban
Craig R. McClanahan wrote:
>
>On Wed, 7 Aug 2002, Olivier Libouban wrote:
>
>>Date: Wed, 07 Aug 2002 10:41:14 -0600
>>From: Olivier Libouban <li...@bea.com>
>>Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
>>To: Struts Users Mailing List <st...@jakarta.apache.org>
>>Subject: Re: Do sub-apps work?
>>
>>I guess they don't.
>>
>
>Are you obeying the restriction that *all* requests must flow through the
>controller servlet? In other words, you cannot have any hyperlinks that
>point directly at a JSP page. If you do, that page will always assume it
>is part of the root sub-app instead of the correct one.
>
>This is a restriction due to the fact that Struts cannot use Filters yet
>-- we are still requiring only the Servlet 2.2 / JSP 1.1 platform. It
>will go away in a future version of Struts, where we can configure a
>filter that does the sub-app assignment for all requests, no matter what
>the URL is.
>
>Craig
>
>>This is what I figured out:
>>The FormTag does not look at
>>sub-app configuration, only the main one.
>>I put the following code in it, to verify that was
>>the case:
>>---------------- **HACKED** FormTag.java, lookup method-------
>> protected void lookup() throws JspException {
>>
>> // Look up the application configuration information we need
>> appConfig = (ApplicationConfig)
>> pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
>>
>> System.out.println("FormTag: Action.APPLICATION_KEY = '" +
>>Action.APPLICATION_KEY);
>> if (appConfig == null)
>> {
>> // GET THE PREFIX SOMEHOW THIS IS A HACK FOR ME ONLY. Olivier.!!
>> String prefix = "/sub-app";
>> appConfig = (ApplicationConfig)
>>
>>pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY +
>>prefix);
>> System.out.println("FormTag: hack for = '" +
>>Action.APPLICATION_KEY + prefix);
>> }
>>-----------------------------------------------------------------------------
>>You will notive the "if (appConfig == null), get the appConfig using a
>>PREFIX,
>>(here hard-coded for my purpose.
>>
>>At that point, I modified the operate command to indicate /operation.jsp
>>instead of /sub-app/operation in 'struts-question-config.xml', since the
>>sub-app
>>portion gets added at run-time. It now ... kind'o works. I have not
>>looked at
>>other tags, but I suspect the same there.
>>
>>Olivier Libouban
>>
>>
>>Olivier Libouban wrote:
>>
>>> I've configured a simplistic sub-app, using
>>>the web.xml init-param:
>>>------------------------ web.xml ----------------------
>>> <servlet>
>>> <servlet-name>action</servlet-name>
>>> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
>>> <init-param>
>>> <param-name>config</param-name>
>>> <param-value>/WEB-INF/struts-main-config.xml</param-value>
>>> </init-param>
>>> <init-param>
>>> <param-name>config/sub-app</param-name>
>>> <param-value>/WEB-INF/struts-question-config.xml</param-value>
>>> </init-param>
>>>---------------------------------------------------------
>>>
>>>In struts-question-config.xml, (for the sub-app), I have an action:
>>>---------------- struts-question-config.xml -------------
>>> <!-- Computation -->
>>> <!-- The same form is used for both the subtraction and the
>>>computation -->
>>> <action path="/sub-app/operate"
>>> type="org.apache.struts.webapp.example.ComputeDispatchAction"
>>> parameter="method"
>>> name="subtractionForm"
>>> scope="request"
>>> validate="true"
>>> input="/sub-app/operation.jsp">
>>> <forward name="success" path="/sub-app/operation.jsp"
>>>redirect="false" />
>>> </action>
>>>---------------------------------------------------------
>>>
>>>
>>>Finally, under 'sub-app/operation.jsp', a form is used to call
>>>the action 'sub-app/operate'.
>>>------------ operation.jsp --------------------------------
>>>[...]
>>><html:form action="/sub-app/operate.do">
>>>[...]
>>>-----------------------------------------------------------
>>>
>>>
>>>Going to 'sub-app/operation.jsp' URL, I get
>>>this message:
>>>------------ Browser -----------------------------------------
>>>[ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
>>>for action /sub-app/operate'
>>>-----------------------------------------------------------------------------------------------
>>>
>>>
>>>
>>>In 4.1.7b1, the 'init' method of ActionServlet was not being called.
>>>(That's were the parsing for the config seems to happen). I switched
>>>over to 4.0.4, and I do see:
>>>------------------- stdout for Tomcat 4.0.4. ----------------------
>>>[INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
>>>[INFO] ActionServlet - -Initializing application path '' configuration
>>>from '/WE
>>>B-INF/struts-main-config.xml'
>>>[INFO] MemoryDatabasePlugIn - -Initializing memory database plug in
>>>from '/WEB-I
>>>NF/database.xml'
>>>[INFO] ActionServlet - -Initializing application path '/sub-app'
>>>configuration f
>>>rom '/WEB-INF/struts-question-config.xml'
>>>-------------------------------------------------------------------
>>>
>>>which seems to indicate the sub-app web.xml entry did get parsed,
>>>
>>>
>>>What am I missing?
>>>
>>>Thanks,
>>>
>>>Olivier Libouban
>>>
>>>
>>>
>>
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
Re: Do sub-apps work?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 7 Aug 2002, Olivier Libouban wrote:
> Date: Wed, 07 Aug 2002 10:41:14 -0600
> From: Olivier Libouban <li...@bea.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Do sub-apps work?
>
> I guess they don't.
>
Are you obeying the restriction that *all* requests must flow through the
controller servlet? In other words, you cannot have any hyperlinks that
point directly at a JSP page. If you do, that page will always assume it
is part of the root sub-app instead of the correct one.
This is a restriction due to the fact that Struts cannot use Filters yet
-- we are still requiring only the Servlet 2.2 / JSP 1.1 platform. It
will go away in a future version of Struts, where we can configure a
filter that does the sub-app assignment for all requests, no matter what
the URL is.
Craig
> This is what I figured out:
> The FormTag does not look at
> sub-app configuration, only the main one.
> I put the following code in it, to verify that was
> the case:
> ---------------- **HACKED** FormTag.java, lookup method-------
> protected void lookup() throws JspException {
>
> // Look up the application configuration information we need
> appConfig = (ApplicationConfig)
> pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
>
> System.out.println("FormTag: Action.APPLICATION_KEY = '" +
> Action.APPLICATION_KEY);
> if (appConfig == null)
> {
> // GET THE PREFIX SOMEHOW THIS IS A HACK FOR ME ONLY. Olivier.!!
> String prefix = "/sub-app";
> appConfig = (ApplicationConfig)
>
> pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY +
> prefix);
> System.out.println("FormTag: hack for = '" +
> Action.APPLICATION_KEY + prefix);
> }
> -----------------------------------------------------------------------------
> You will notive the "if (appConfig == null), get the appConfig using a
> PREFIX,
> (here hard-coded for my purpose.
>
> At that point, I modified the operate command to indicate /operation.jsp
> instead of /sub-app/operation in 'struts-question-config.xml', since the
> sub-app
> portion gets added at run-time. It now ... kind'o works. I have not
> looked at
> other tags, but I suspect the same there.
>
> Olivier Libouban
>
>
> Olivier Libouban wrote:
>
> > I've configured a simplistic sub-app, using
> > the web.xml init-param:
> > ------------------------ web.xml ----------------------
> > <servlet>
> > <servlet-name>action</servlet-name>
> > <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> > <init-param>
> > <param-name>config</param-name>
> > <param-value>/WEB-INF/struts-main-config.xml</param-value>
> > </init-param>
> > <init-param>
> > <param-name>config/sub-app</param-name>
> > <param-value>/WEB-INF/struts-question-config.xml</param-value>
> > </init-param>
> > ---------------------------------------------------------
> >
> > In struts-question-config.xml, (for the sub-app), I have an action:
> > ---------------- struts-question-config.xml -------------
> > <!-- Computation -->
> > <!-- The same form is used for both the subtraction and the
> > computation -->
> > <action path="/sub-app/operate"
> > type="org.apache.struts.webapp.example.ComputeDispatchAction"
> > parameter="method"
> > name="subtractionForm"
> > scope="request"
> > validate="true"
> > input="/sub-app/operation.jsp">
> > <forward name="success" path="/sub-app/operation.jsp"
> > redirect="false" />
> > </action>
> > ---------------------------------------------------------
> >
> >
> > Finally, under 'sub-app/operation.jsp', a form is used to call
> > the action 'sub-app/operate'.
> > ------------ operation.jsp --------------------------------
> > [...]
> > <html:form action="/sub-app/operate.do">
> > [...]
> > -----------------------------------------------------------
> >
> >
> > Going to 'sub-app/operation.jsp' URL, I get
> > this message:
> > ------------ Browser -----------------------------------------
> > [ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
> > for action /sub-app/operate'
> > -----------------------------------------------------------------------------------------------
> >
> >
> >
> > In 4.1.7b1, the 'init' method of ActionServlet was not being called.
> > (That's were the parsing for the config seems to happen). I switched
> > over to 4.0.4, and I do see:
> > ------------------- stdout for Tomcat 4.0.4. ----------------------
> > [INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
> > [INFO] ActionServlet - -Initializing application path '' configuration
> > from '/WE
> > B-INF/struts-main-config.xml'
> > [INFO] MemoryDatabasePlugIn - -Initializing memory database plug in
> > from '/WEB-I
> > NF/database.xml'
> > [INFO] ActionServlet - -Initializing application path '/sub-app'
> > configuration f
> > rom '/WEB-INF/struts-question-config.xml'
> > -------------------------------------------------------------------
> >
> > which seems to indicate the sub-app web.xml entry did get parsed,
> >
> >
> > What am I missing?
> >
> > Thanks,
> >
> > Olivier Libouban
> >
> >
> >
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Do sub-apps work?
Posted by Olivier Libouban <li...@bea.com>.
I guess they don't.
This is what I figured out:
The FormTag does not look at
sub-app configuration, only the main one.
I put the following code in it, to verify that was
the case:
---------------- **HACKED** FormTag.java, lookup method-------
protected void lookup() throws JspException {
// Look up the application configuration information we need
appConfig = (ApplicationConfig)
pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
System.out.println("FormTag: Action.APPLICATION_KEY = '" +
Action.APPLICATION_KEY);
if (appConfig == null)
{
// GET THE PREFIX SOMEHOW THIS IS A HACK FOR ME ONLY. Olivier.!!
String prefix = "/sub-app";
appConfig = (ApplicationConfig)
pageContext.getServletContext().getAttribute(Action.APPLICATION_KEY +
prefix);
System.out.println("FormTag: hack for = '" +
Action.APPLICATION_KEY + prefix);
}
-----------------------------------------------------------------------------
You will notive the "if (appConfig == null), get the appConfig using a
PREFIX,
(here hard-coded for my purpose.
At that point, I modified the operate command to indicate /operation.jsp
instead of /sub-app/operation in 'struts-question-config.xml', since the
sub-app
portion gets added at run-time. It now ... kind'o works. I have not
looked at
other tags, but I suspect the same there.
Olivier Libouban
Olivier Libouban wrote:
> I've configured a simplistic sub-app, using
> the web.xml init-param:
> ------------------------ web.xml ----------------------
> <servlet>
> <servlet-name>action</servlet-name>
> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
> <init-param>
> <param-name>config</param-name>
> <param-value>/WEB-INF/struts-main-config.xml</param-value>
> </init-param>
> <init-param>
> <param-name>config/sub-app</param-name>
> <param-value>/WEB-INF/struts-question-config.xml</param-value>
> </init-param>
> ---------------------------------------------------------
>
> In struts-question-config.xml, (for the sub-app), I have an action:
> ---------------- struts-question-config.xml -------------
> <!-- Computation -->
> <!-- The same form is used for both the subtraction and the
> computation -->
> <action path="/sub-app/operate"
> type="org.apache.struts.webapp.example.ComputeDispatchAction"
> parameter="method"
> name="subtractionForm"
> scope="request"
> validate="true"
> input="/sub-app/operation.jsp">
> <forward name="success" path="/sub-app/operation.jsp"
> redirect="false" />
> </action>
> ---------------------------------------------------------
>
>
> Finally, under 'sub-app/operation.jsp', a form is used to call
> the action 'sub-app/operate'.
> ------------ operation.jsp --------------------------------
> [...]
> <html:form action="/sub-app/operate.do">
> [...]
> -----------------------------------------------------------
>
>
> Going to 'sub-app/operation.jsp' URL, I get
> this message:
> ------------ Browser -----------------------------------------
> [ServletException in:/sub-app/operation.jsp] Cannot retrieve mapping
> for action /sub-app/operate'
> -----------------------------------------------------------------------------------------------
>
>
>
> In 4.1.7b1, the 'init' method of ActionServlet was not being called.
> (That's were the parsing for the config seems to happen). I switched
> over to 4.0.4, and I do see:
> ------------------- stdout for Tomcat 4.0.4. ----------------------
> [INFO] ActionServlet - -Process servletName=action, urlPattern=*.do
> [INFO] ActionServlet - -Initializing application path '' configuration
> from '/WE
> B-INF/struts-main-config.xml'
> [INFO] MemoryDatabasePlugIn - -Initializing memory database plug in
> from '/WEB-I
> NF/database.xml'
> [INFO] ActionServlet - -Initializing application path '/sub-app'
> configuration f
> rom '/WEB-INF/struts-question-config.xml'
> -------------------------------------------------------------------
>
> which seems to indicate the sub-app web.xml entry did get parsed,
>
>
> What am I missing?
>
> Thanks,
>
> Olivier Libouban
>
>
>