You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alec Bickerton <al...@minick.ch> on 2008/02/04 12:31:43 UTC
Psuedo protocol as a action parameter causing problems
Hi,
I have simple action that takes 3 parameter and does a simple redirect
based on the value of param1.
e.g.,
<map:match pattern="blah">
<map:act type="SimpleAction">
<map:parameter name="ua" value="{useragent}"/>
<map:parameter name="one" value="http://somehost/someurl"/>
<map:parameter name="two" value="http://somehost/someotherURL"/>
</map:act>
</map:match>
Works perfectly, however the application I'm working on requires the use
of cocoon:// as parameters.
The following fails as the cocoon://url cannot be properly resolved by
the action.
<map:match pattern="blah">
<map:act type="SimpleAction">
<map:parameter name="ua" value="{useragent}"/>
<map:parameter name="one" value="cocoon://someurl"/>
<map:parameter name="two" value="cocoon://someotherURL"/>
</map:act>
</map:match>
SimpleAction.java (Simplified for clarity)
public class SimpleAction extends AbstractAction {
public final Map act( final Redirector redirector, final SourceResolver
resolver, final Map objectModel, final String source,final Parameters
params) throws Exception {
String ua = "example";
String oneURL = "www.example.example/pass/";
String twoURL = "www.example.example/fail/";
if( params.isParameter( "ua" ) )
ua = params.getParameter( ua );
if( params.isParameter( "one" ) )
oneURL = params.getParameter( "one" );
if( params.isParameter( "two" ) )
twoURL = params.getParameter( "two" );
if( ua.equals("something"))
redirector.redirect( false, oneURL );
else
redirector.redirect( false, twoURL );
return null;
}
Any ideas. Is there a mechanism that I can retrieve the absolute URL
from the cocoon:// protocol from within an action.
Or am I missing some magic incantation on the redirector, that would let
me use this type of URL.
Any help would be most appreciated.
Alec
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Psuedo protocol as a action parameter causing problems
Posted by Carsten Ziegeler <cz...@apache.org>.
Alec Bickerton schrieb:
> Carsten,
>
> That is what I'm expecting, but for some reason. The redirect is not a
> the url does become the new url.
>
> There are no errors on the console, what is going wrong occurs in
> somewhere in the pipeline. Here's a more concrete example.
>
> For example.
>
> If I make a request to http://myserver/blah I would expect to be
> redirected to the http://myserver/someotherUrl and the request object in
> the action to show the correct URL. This it does.
>
> where there is a matcher
>
> <map:match pattern="**/someotherUrl">
> <map:act type="SimpleAction">
> <map:parameter name="ua" value="{useragent}"/>
> <map:parameter name="two" value="cocoon://{1}/tools/somecheck.jsp" />
> </map:act>
> </map:match>
>
> Once the matches and the request gets to the jsp the
> request.getRequestURI reads myserver/someotherUrl and not
> myserver/tools/somecheck.jsp as I would be expecting.
>
> As I wrote earlier, if a real http:// url is used, the url appears
> correctly in the request to the jsp.
>
> Btw, The cocoon version being used is 2.1.9.
>
Ok, there are two problems :)
The first one is that if you use the cocoon: protocol, the redirect is
handled internally, so the browser is not redirecting and is never
notified that a redirect took place. If you want the browser to redirect
you have to use the fully qualified url (using http). I'm not sure, but
it could be that we have some input modules generating the full url for
you, so you might not have to hard code the server name etc. in your
sitemap. You can check the existing input modules for this. If it's not
available I would suggest that you either write an input module for this
or do this inside your action.
The second problem is that jsp access does not work for internal
redirects. And this is a bug.
HTH
Carsten
--
Carsten Ziegeler
cziegeler@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Psuedo protocol as a action parameter causing problems
Posted by Alec Bickerton <al...@minick.ch>.
Carsten,
That is what I'm expecting, but for some reason. The redirect is not a
the url does become the new url.
There are no errors on the console, what is going wrong occurs in
somewhere in the pipeline. Here's a more concrete example.
For example.
If I make a request to http://myserver/blah I would expect to be
redirected to the http://myserver/someotherUrl and the request object in
the action to show the correct URL. This it does.
where there is a matcher
<map:match pattern="**/someotherUrl">
<map:act type="SimpleAction">
<map:parameter name="ua" value="{useragent}"/>
<map:parameter name="two" value="cocoon://{1}/tools/somecheck.jsp" />
</map:act>
</map:match>
Once the matches and the request gets to the jsp the
request.getRequestURI reads myserver/someotherUrl and not
myserver/tools/somecheck.jsp as I would be expecting.
As I wrote earlier, if a real http:// url is used, the url appears
correctly in the request to the jsp.
Btw, The cocoon version being used is 2.1.9.
Alec.
Carsten Ziegeler wrote:
> Hi,
>
> this should work - the redirector has a built-in handling for cocoon: urls.
>
> Are there any errors when you try it or what is going wrong?
>
> Carsten
>
> Alec Bickerton wrote:
>> Hi,
>>
>> I have simple action that takes 3 parameter and does a simple redirect
>> based on the value of param1.
>>
>> e.g.,
>>
>> <map:match pattern="blah">
>> <map:act type="SimpleAction">
>> <map:parameter name="ua" value="{useragent}"/>
>> <map:parameter name="one" value="http://somehost/someurl"/>
>> <map:parameter name="two" value="http://somehost/someotherURL"/>
>> </map:act>
>> </map:match>
>>
>> Works perfectly, however the application I'm working on requires the
>> use of cocoon:// as parameters.
>> The following fails as the cocoon://url cannot be properly resolved by
>> the action.
>>
>> <map:match pattern="blah">
>> <map:act type="SimpleAction">
>> <map:parameter name="ua" value="{useragent}"/>
>> <map:parameter name="one" value="cocoon://someurl"/>
>> <map:parameter name="two" value="cocoon://someotherURL"/>
>> </map:act>
>> </map:match>
>>
>>
>> SimpleAction.java (Simplified for clarity)
>>
>> public class SimpleAction extends AbstractAction {
>>
>> public final Map act( final Redirector redirector, final
>> SourceResolver resolver, final Map objectModel, final String
>> source,final Parameters params) throws Exception {
>> String ua = "example";
>> String oneURL = "www.example.example/pass/";
>> String twoURL = "www.example.example/fail/";
>> if( params.isParameter( "ua" ) )
>> ua = params.getParameter( ua );
>> if( params.isParameter( "one" ) )
>> oneURL = params.getParameter( "one" );
>> if( params.isParameter( "two" ) )
>> twoURL = params.getParameter( "two" );
>> if( ua.equals("something"))
>> redirector.redirect( false, oneURL );
>> else
>> redirector.redirect( false, twoURL );
>> return null;
>> }
>>
>>
>> Any ideas. Is there a mechanism that I can retrieve the absolute URL
>> from the cocoon:// protocol from within an action.
>> Or am I missing some magic incantation on the redirector, that would
>> let me use this type of URL.
>>
>> Any help would be most appreciated.
>> Alec
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Psuedo protocol as a action parameter causing problems
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
this should work - the redirector has a built-in handling for cocoon: urls.
Are there any errors when you try it or what is going wrong?
Carsten
Alec Bickerton wrote:
> Hi,
>
> I have simple action that takes 3 parameter and does a simple redirect
> based on the value of param1.
>
> e.g.,
>
> <map:match pattern="blah">
> <map:act type="SimpleAction">
> <map:parameter name="ua" value="{useragent}"/>
> <map:parameter name="one" value="http://somehost/someurl"/>
> <map:parameter name="two" value="http://somehost/someotherURL"/>
> </map:act>
> </map:match>
>
> Works perfectly, however the application I'm working on requires the use
> of cocoon:// as parameters.
> The following fails as the cocoon://url cannot be properly resolved by
> the action.
>
> <map:match pattern="blah">
> <map:act type="SimpleAction">
> <map:parameter name="ua" value="{useragent}"/>
> <map:parameter name="one" value="cocoon://someurl"/>
> <map:parameter name="two" value="cocoon://someotherURL"/>
> </map:act>
> </map:match>
>
>
> SimpleAction.java (Simplified for clarity)
>
> public class SimpleAction extends AbstractAction {
>
> public final Map act( final Redirector redirector, final SourceResolver
> resolver, final Map objectModel, final String source,final Parameters
> params) throws Exception {
> String ua = "example";
> String oneURL = "www.example.example/pass/";
> String twoURL = "www.example.example/fail/";
> if( params.isParameter( "ua" ) )
> ua = params.getParameter( ua );
> if( params.isParameter( "one" ) )
> oneURL = params.getParameter( "one" );
> if( params.isParameter( "two" ) )
> twoURL = params.getParameter( "two" );
> if( ua.equals("something"))
> redirector.redirect( false, oneURL );
> else
> redirector.redirect( false, twoURL );
> return null;
> }
>
>
> Any ideas. Is there a mechanism that I can retrieve the absolute URL
> from the cocoon:// protocol from within an action.
> Or am I missing some magic incantation on the redirector, that would let
> me use this type of URL.
>
> Any help would be most appreciated.
> Alec
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Carsten Ziegeler
cziegeler@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org