How to get both querystring and form parameters?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get both querystring and form parameters?

david
Hi everyone,

My need is rather special, maybe a little weird, but I have to deal with it (I have to respect a kind of protocol):
I'm accessing an URL managed by Hippo through a GET or a POST request.
Let's call this URL : /site/myservice
This URL is defined in hst:sitemap and bound to a component which will do many cool things :)

When accessing with a GET request, I don't have any problem... My URL is something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
When I'm accessing using a POST I have to add a new parameter (third one in my example, let's say PARAM3=CCC), but this time this parameter IS NOT added to the querystring, but as a regular form parameter... You can figure the whole thing as a HTML form like this :

<form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">
   <input type="hidden" name="PARAM3" value="CCC" />
</form>


And this is where I'm stuck: This parameter isn't accessible from my component, using the HstRequest object... The parameters map only has the querystring parameters...

Is there any trick to enable this? In a classic Java EE development such a mix is gracefully handled and all the parameters are accessible through the parameters map, but due to the way Hippo handle the request, that's not longer true in my particular case.

Any help appreciated.

Have a nice WE everyone.

David


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Wouter Danes-2

Request.getPublicParameter probably. J

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: Friday, March 8, 2013 5:51 PM
To: Hippo CMS 7 development public mailinglist
Subject: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi everyone,

 

My need is rather special, maybe a little weird, but I have to deal with it (I have to respect a kind of protocol):

I'm accessing an URL managed by Hippo through a GET or a POST request.

Let's call this URL : /site/myservice

This URL is defined in hst:sitemap and bound to a component which will do many cool things :)

 

When accessing with a GET request, I don't have any problem... My URL is something like /site/myservice?PARAM1=AAA&PARAM2=BBBB

When I'm accessing using a POST I have to add a new parameter (third one in my example, let's say PARAM3=CCC), but this time this parameter IS NOT added to the querystring, but as a regular form parameter... You can figure the whole thing as a HTML form like this :

 

<form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

   <input type="hidden" name="PARAM3" value="CCC" />

</form>

 

 

And this is where I'm stuck: This parameter isn't accessible from my component, using the HstRequest object... The parameters map only has the querystring parameters...

 

Is there any trick to enable this? In a classic Java EE development such a mix is gracefully handled and all the parameters are accessible through the parameters map, but due to the way Hippo handle the request, that's not longer true in my particular case.

 

Any help appreciated.

 

Have a nice WE everyone.

 

David

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Michiel Rop
In reply to this post by david
Hi David,

The way HST components handle post request is described at [1]. 

One way to do this is:

<hst:actionURL  var="url"/>
<form action="${url}" method="post">
    <input type="hidden" name="PARAM3" value="CCC" />
   .....
</form>

In the doAction you can read PARAM3 and add the get parameters [3].  





[3]
Map<String,String[]> parameters = new HashMap<String,String[]>();
        parameters.put("PARAM1", new String[]{"AAA"});
        parameters.put("PARAM2", new String[]{"BBB"});

        response.setRenderParameters(parameters);


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:
Hi everyone,

My need is rather special, maybe a little weird, but I have to deal with it (I have to respect a kind of protocol):
I'm accessing an URL managed by Hippo through a GET or a POST request.
Let's call this URL : /site/myservice
This URL is defined in hst:sitemap and bound to a component which will do many cool things :)

When accessing with a GET request, I don't have any problem... My URL is something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
When I'm accessing using a POST I have to add a new parameter (third one in my example, let's say PARAM3=CCC), but this time this parameter IS NOT added to the querystring, but as a regular form parameter... You can figure the whole thing as a HTML form like this :

<form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">
   <input type="hidden" name="PARAM3" value="CCC" />
</form>


And this is where I'm stuck: This parameter isn't accessible from my component, using the HstRequest object... The parameters map only has the querystring parameters...

Is there any trick to enable this? In a classic Java EE development such a mix is gracefully handled and all the parameters are accessible through the parameters map, but due to the way Hippo handle the request, that's not longer true in my particular case.

Any help appreciated.

Have a nice WE everyone.

David


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Met vriendelijke groet, / Best regards,
Michiel Rop
+31 (0)6 5279 2264

--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Ard
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Ard
In reply to this post by david
Hello,

On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.

>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard

>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

david
Hi,

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

David


On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:
Hello,

On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:
> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.

>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard

>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466">+31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Ard
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Ard
On Mon, Mar 11, 2013 at 9:42 AM, David Martin <[hidden email]> wrote:
> Hi,
>
> Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy
> that I'm rather ashamed for not having seen this before :)
>
> Regarding the others suggestions (Michiel and Ard), unfortunately, I can't
> use any hst:actionURL like URL since my service is a public entry point that
> can't be dynamically created: some other users, outside the scope of Hippo,

Note that in general for idempotent requests you also do not want a
hst:actionURL. So for example for a search that uses a form, you
should never use an actionURL.

> are accessing the service using a predetermined and immutable URL (in my
> example /site/myservice, but of course in production, there is no "site" as
> the site application root is bound to /) and kind of protocol (the one I've
> described above).
>
> I'll get back to you as soon as tomorrow, with Wouter's suggestion live
> results :)

I just don't understand how come that the other request parameters
which are un-namespaced can be read, but the one from the post cannot
be read. That doesn't make sense. I would expect the request params in
the URL cannot be read either. You might consider for your usecase to
run the application with

parameter.namespace.ignored = true

in that case, you do not need to 'think' about public request
parameters at all any more as all request parameters are then
un-namespaced

Regards Ard

>
> David
>
>
> On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]>
> wrote:
>>
>> Hello,
>>
>> On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:
>> > Hi everyone,
>> >
>> > My need is rather special, maybe a little weird, but I have to deal with
>> > it
>> > (I have to respect a kind of protocol):
>> > I'm accessing an URL managed by Hippo through a GET or a POST request.
>> > Let's call this URL : /site/myservice
>> > This URL is defined in hst:sitemap and bound to a component which will
>> > do
>> > many cool things :)
>> >
>> > When accessing with a GET request, I don't have any problem... My URL is
>> > something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
>> > When I'm accessing using a POST I have to add a new parameter (third one
>> > in
>> > my example, let's say PARAM3=CCC), but this time this parameter IS NOT
>> > added
>> > to the querystring, but as a regular form parameter... You can figure
>> > the
>> > whole thing as a HTML form like this :
>> >
>> > <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">
>>
>> You should refrain from using /site explicitly in your urls : I assume
>> you do not want your URLs in production to all start with /site,
>> right? That is why you need to use hst:link, hst:renderURL,
>> hst:actionURL etc for links. For these links, you never specify the
>> contextpath. The HST will include the contextpath depending on
>> hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
>> way, you can switch off contextpath in prod when httpd takes care of
>> /site part.
>>
>> >    <input type="hidden" name="PARAM3" value="CCC" />
>> > </form>
>> >
>> >
>> > And this is where I'm stuck: This parameter isn't accessible from my
>> > component, using the HstRequest object... The parameters map only has
>> > the
>> > querystring parameters...
>>
>> As explained above, you can better use hst:link or hst:actionURL to
>> create the link for action attr in form:
>>
>> 1) Use hst:link if your form should hit doBeforeRender method
>> 2) Use hst:actionURL if your form should hit doAction (for example to
>> really modify data)
>>
>> To include query queparameters in a hst:link you use hst:param tags.
>> These will be namespaced, such that in doBeforeRender the
>> hstRequest.getParameter("someParam") can be read, even though in the
>> queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
>> is the namespace of the component that will be able to read the
>> someParam parameter.
>>
>> How, in your case, the PARAM3 is part of the form, which are
>> un-namespaced parameters. To read them in doAction method you can just
>> use hstRequest.getParameter("PARAM3"). However, to read them in
>> doBeforeRender you need to explicitly mention you want to fetch an
>> un-namespaced parameters, hence, as Wouter points out, use
>> getPublicRequestParameter.
>>
>> If you do not want all the namespacing going on as explained in a
>> nutshell above, you can set in your hst-config.properties
>>
>> parameter.namespace.ignored = true
>>
>> Note that you then do loose some features that are supported through
>> parameter namespacing
>>
>> Regards Ard
>>
>> >
>> > Is there any trick to enable this? In a classic Java EE development such
>> > a
>> > mix is gracefully handled and all the parameters are accessible through
>> > the
>> > parameters map, but due to the way Hippo handle the request, that's not
>> > longer true in my particular case.
>> >
>> > Any help appreciated.
>> >
>> > Have a nice WE everyone.
>> >
>> > David
>> >
>> >
>> > _______________________________________________
>> > Hippo-cms7-user mailing list and forums
>> > http://www.onehippo.org/cms7/support/forums.html
>>
>>
>>
>> --
>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>> Boston - 1 Broadway, Cambridge, MA 02142
>>
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>> www.onehippo.com
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

david
Ok, I'd seen this parameter (parameter.namespace.ignored = [true|false]) but didn't give it a try until now.
As parameters are application wide un-namespaced, it can bring more problems than solutions, right ?
Is there any possibility to only enable this on a particular path (for a specific sitemap, or component, ... ) ?

David


On Mon, Mar 11, 2013 at 9:49 AM, Ard Schrijvers <[hidden email]> wrote:
On Mon, Mar 11, 2013 at 9:42 AM, David Martin <[hidden email]> wrote:
> Hi,
>
> Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy
> that I'm rather ashamed for not having seen this before :)
>
> Regarding the others suggestions (Michiel and Ard), unfortunately, I can't
> use any hst:actionURL like URL since my service is a public entry point that
> can't be dynamically created: some other users, outside the scope of Hippo,

Note that in general for idempotent requests you also do not want a
hst:actionURL. So for example for a search that uses a form, you
should never use an actionURL.

> are accessing the service using a predetermined and immutable URL (in my
> example /site/myservice, but of course in production, there is no "site" as
> the site application root is bound to /) and kind of protocol (the one I've
> described above).
>
> I'll get back to you as soon as tomorrow, with Wouter's suggestion live
> results :)

I just don't understand how come that the other request parameters
which are un-namespaced can be read, but the one from the post cannot
be read. That doesn't make sense. I would expect the request params in
the URL cannot be read either. You might consider for your usecase to
run the application with

parameter.namespace.ignored = true

in that case, you do not need to 'think' about public request
parameters at all any more as all request parameters are then
un-namespaced

Regards Ard

>
> David
>
>
> On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]>
> wrote:
>>
>> Hello,
>>
>> On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:
>> > Hi everyone,
>> >
>> > My need is rather special, maybe a little weird, but I have to deal with
>> > it
>> > (I have to respect a kind of protocol):
>> > I'm accessing an URL managed by Hippo through a GET or a POST request.
>> > Let's call this URL : /site/myservice
>> > This URL is defined in hst:sitemap and bound to a component which will
>> > do
>> > many cool things :)
>> >
>> > When accessing with a GET request, I don't have any problem... My URL is
>> > something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
>> > When I'm accessing using a POST I have to add a new parameter (third one
>> > in
>> > my example, let's say PARAM3=CCC), but this time this parameter IS NOT
>> > added
>> > to the querystring, but as a regular form parameter... You can figure
>> > the
>> > whole thing as a HTML form like this :
>> >
>> > <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">
>>
>> You should refrain from using /site explicitly in your urls : I assume
>> you do not want your URLs in production to all start with /site,
>> right? That is why you need to use hst:link, hst:renderURL,
>> hst:actionURL etc for links. For these links, you never specify the
>> contextpath. The HST will include the contextpath depending on
>> hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
>> way, you can switch off contextpath in prod when httpd takes care of
>> /site part.
>>
>> >    <input type="hidden" name="PARAM3" value="CCC" />
>> > </form>
>> >
>> >
>> > And this is where I'm stuck: This parameter isn't accessible from my
>> > component, using the HstRequest object... The parameters map only has
>> > the
>> > querystring parameters...
>>
>> As explained above, you can better use hst:link or hst:actionURL to
>> create the link for action attr in form:
>>
>> 1) Use hst:link if your form should hit doBeforeRender method
>> 2) Use hst:actionURL if your form should hit doAction (for example to
>> really modify data)
>>
>> To include query queparameters in a hst:link you use hst:param tags.
>> These will be namespaced, such that in doBeforeRender the
>> hstRequest.getParameter("someParam") can be read, even though in the
>> queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
>> is the namespace of the component that will be able to read the
>> someParam parameter.
>>
>> How, in your case, the PARAM3 is part of the form, which are
>> un-namespaced parameters. To read them in doAction method you can just
>> use hstRequest.getParameter("PARAM3"). However, to read them in
>> doBeforeRender you need to explicitly mention you want to fetch an
>> un-namespaced parameters, hence, as Wouter points out, use
>> getPublicRequestParameter.
>>
>> If you do not want all the namespacing going on as explained in a
>> nutshell above, you can set in your hst-config.properties
>>
>> parameter.namespace.ignored = true
>>
>> Note that you then do loose some features that are supported through
>> parameter namespacing
>>
>> Regards Ard
>>
>> >
>> > Is there any trick to enable this? In a classic Java EE development such
>> > a
>> > mix is gracefully handled and all the parameters are accessible through
>> > the
>> > parameters map, but due to the way Hippo handle the request, that's not
>> > longer true in my particular case.
>> >
>> > Any help appreciated.
>> >
>> > Have a nice WE everyone.
>> >
>> > David
>> >
>> >
>> > _______________________________________________
>> > Hippo-cms7-user mailing list and forums
>> > http://www.onehippo.org/cms7/support/forums.html
>>
>>
>>
>> --
>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>> Boston - 1 Broadway, Cambridge, MA 02142
>>
>> US <a href="tel:%2B1%20877%20414%204776" value="+18774144776">+1 877 414 4776 (toll free)
>> Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466">+31(0)20 522 4466
>> www.onehippo.com
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466">+31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
David MARTIN
Ippon Technologies

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Ard
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Ard
On Mon, Mar 11, 2013 at 10:10 AM, David Martin <[hidden email]> wrote:
> Ok, I'd seen this parameter (parameter.namespace.ignored = [true|false]) but
> didn't give it a try until now.
> As parameters are application wide un-namespaced, it can bring more problems
> than solutions, right ?
> Is there any possibility to only enable this on a particular path (for a
> specific sitemap, or component, ... ) ?

No that is not possible :)

Regards Ard

>
> David
>
>
> On Mon, Mar 11, 2013 at 9:49 AM, Ard Schrijvers <[hidden email]>
> wrote:
>>
>> On Mon, Mar 11, 2013 at 9:42 AM, David Martin <[hidden email]> wrote:
>> > Hi,
>> >
>> > Thanks for your feedback. I'll give Wouter's advice a try, it seems so
>> > easy
>> > that I'm rather ashamed for not having seen this before :)
>> >
>> > Regarding the others suggestions (Michiel and Ard), unfortunately, I
>> > can't
>> > use any hst:actionURL like URL since my service is a public entry point
>> > that
>> > can't be dynamically created: some other users, outside the scope of
>> > Hippo,
>>
>> Note that in general for idempotent requests you also do not want a
>> hst:actionURL. So for example for a search that uses a form, you
>> should never use an actionURL.
>>
>> > are accessing the service using a predetermined and immutable URL (in my
>> > example /site/myservice, but of course in production, there is no "site"
>> > as
>> > the site application root is bound to /) and kind of protocol (the one
>> > I've
>> > described above).
>> >
>> > I'll get back to you as soon as tomorrow, with Wouter's suggestion live
>> > results :)
>>
>> I just don't understand how come that the other request parameters
>> which are un-namespaced can be read, but the one from the post cannot
>> be read. That doesn't make sense. I would expect the request params in
>> the URL cannot be read either. You might consider for your usecase to
>> run the application with
>>
>> parameter.namespace.ignored = true
>>
>> in that case, you do not need to 'think' about public request
>> parameters at all any more as all request parameters are then
>> un-namespaced
>>
>> Regards Ard
>>
>> >
>> > David
>> >
>> >
>> > On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers
>> > <[hidden email]>
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:
>> >> > Hi everyone,
>> >> >
>> >> > My need is rather special, maybe a little weird, but I have to deal
>> >> > with
>> >> > it
>> >> > (I have to respect a kind of protocol):
>> >> > I'm accessing an URL managed by Hippo through a GET or a POST
>> >> > request.
>> >> > Let's call this URL : /site/myservice
>> >> > This URL is defined in hst:sitemap and bound to a component which
>> >> > will
>> >> > do
>> >> > many cool things :)
>> >> >
>> >> > When accessing with a GET request, I don't have any problem... My URL
>> >> > is
>> >> > something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
>> >> > When I'm accessing using a POST I have to add a new parameter (third
>> >> > one
>> >> > in
>> >> > my example, let's say PARAM3=CCC), but this time this parameter IS
>> >> > NOT
>> >> > added
>> >> > to the querystring, but as a regular form parameter... You can figure
>> >> > the
>> >> > whole thing as a HTML form like this :
>> >> >
>> >> > <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">
>> >>
>> >> You should refrain from using /site explicitly in your urls : I assume
>> >> you do not want your URLs in production to all start with /site,
>> >> right? That is why you need to use hst:link, hst:renderURL,
>> >> hst:actionURL etc for links. For these links, you never specify the
>> >> contextpath. The HST will include the contextpath depending on
>> >> hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
>> >> way, you can switch off contextpath in prod when httpd takes care of
>> >> /site part.
>> >>
>> >> >    <input type="hidden" name="PARAM3" value="CCC" />
>> >> > </form>
>> >> >
>> >> >
>> >> > And this is where I'm stuck: This parameter isn't accessible from my
>> >> > component, using the HstRequest object... The parameters map only has
>> >> > the
>> >> > querystring parameters...
>> >>
>> >> As explained above, you can better use hst:link or hst:actionURL to
>> >> create the link for action attr in form:
>> >>
>> >> 1) Use hst:link if your form should hit doBeforeRender method
>> >> 2) Use hst:actionURL if your form should hit doAction (for example to
>> >> really modify data)
>> >>
>> >> To include query queparameters in a hst:link you use hst:param tags.
>> >> These will be namespaced, such that in doBeforeRender the
>> >> hstRequest.getParameter("someParam") can be read, even though in the
>> >> queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
>> >> is the namespace of the component that will be able to read the
>> >> someParam parameter.
>> >>
>> >> How, in your case, the PARAM3 is part of the form, which are
>> >> un-namespaced parameters. To read them in doAction method you can just
>> >> use hstRequest.getParameter("PARAM3"). However, to read them in
>> >> doBeforeRender you need to explicitly mention you want to fetch an
>> >> un-namespaced parameters, hence, as Wouter points out, use
>> >> getPublicRequestParameter.
>> >>
>> >> If you do not want all the namespacing going on as explained in a
>> >> nutshell above, you can set in your hst-config.properties
>> >>
>> >> parameter.namespace.ignored = true
>> >>
>> >> Note that you then do loose some features that are supported through
>> >> parameter namespacing
>> >>
>> >> Regards Ard
>> >>
>> >> >
>> >> > Is there any trick to enable this? In a classic Java EE development
>> >> > such
>> >> > a
>> >> > mix is gracefully handled and all the parameters are accessible
>> >> > through
>> >> > the
>> >> > parameters map, but due to the way Hippo handle the request, that's
>> >> > not
>> >> > longer true in my particular case.
>> >> >
>> >> > Any help appreciated.
>> >> >
>> >> > Have a nice WE everyone.
>> >> >
>> >> > David
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Hippo-cms7-user mailing list and forums
>> >> > http://www.onehippo.org/cms7/support/forums.html
>> >>
>> >>
>> >>
>> >> --
>> >> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>> >> Boston - 1 Broadway, Cambridge, MA 02142
>> >>
>> >> US +1 877 414 4776 (toll free)
>> >> Europe +31(0)20 522 4466
>> >> www.onehippo.com
>> >> _______________________________________________
>> >> Hippo-cms7-user mailing list and forums
>> >> http://www.onehippo.org/cms7/support/forums.html
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > Hippo-cms7-user mailing list and forums
>> > http://www.onehippo.org/cms7/support/forums.html
>>
>>
>>
>> --
>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>> Boston - 1 Broadway, Cambridge, MA 02142
>>
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>> www.onehippo.com
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
>
> --
> David MARTIN
> Ippon Technologies
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Wouter Danes-2
In reply to this post by david

If your “service” is a kind of webservice, you might want to look into a REST mount / api for this?

Hippo supports Apache CXF out of the box, which should make things a lot easier.

What are you trying to accomplish?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 9:42
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi,

 

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

 

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

 

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

 

David

 

On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:

Hello,


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.


>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard


>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>

> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

david
It is not a webservice. In fact, it acts as a dispatcher. Depending on the parameters set received, it's goal is to redirect to a particular URL (among several possibilities) of the application (which is bound to a specific component: a proxy component that routes some of the parameters to a backend service).
As the configuration of this "dispatcher" is stored in JCR, and related to the application's sitemap, I've decided to implement it as a Hippo managed URL. Thus, this is a dedicated entry in the sitemap that uses a specific component.

I can't test your suggestion today (not working on this project), but I'll test it tomorrow before anything else and let you know if it solves my trouble...

Have a nice day

David


On Mon, Mar 11, 2013 at 1:47 PM, Wouter Danes <[hidden email]> wrote:

If your “service” is a kind of webservice, you might want to look into a REST mount / api for this?

Hippo supports Apache CXF out of the box, which should make things a lot easier.

What are you trying to accomplish?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 9:42
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi,

 

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

 

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

 

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

 

David

 

On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:

Hello,


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.


>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard


>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>

> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
David MARTIN
Ippon Technologies

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

Wouter Danes-2

AFAIK, there’s request.getRequestContext().getServletRequest() if you want to work on “Servlet level”..

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 14:30
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

It is not a webservice. In fact, it acts as a dispatcher. Depending on the parameters set received, it's goal is to redirect to a particular URL (among several possibilities) of the application (which is bound to a specific component: a proxy component that routes some of the parameters to a backend service).

As the configuration of this "dispatcher" is stored in JCR, and related to the application's sitemap, I've decided to implement it as a Hippo managed URL. Thus, this is a dedicated entry in the sitemap that uses a specific component.

 

I can't test your suggestion today (not working on this project), but I'll test it tomorrow before anything else and let you know if it solves my trouble...

 

Have a nice day

 

David

 

On Mon, Mar 11, 2013 at 1:47 PM, Wouter Danes <[hidden email]> wrote:

If your “service” is a kind of webservice, you might want to look into a REST mount / api for this?

Hippo supports Apache CXF out of the box, which should make things a lot easier.

What are you trying to accomplish?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 9:42
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi,

 

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

 

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

 

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

 

David

 

On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:

Hello,


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.


>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard


>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>

> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



 

--
David MARTIN
Ippon Technologies


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

david
Good to know. I'll add this tip to my check list for tomorrow.
Thanks

David


On Mon, Mar 11, 2013 at 2:33 PM, Wouter Danes <[hidden email]> wrote:

AFAIK, there’s request.getRequestContext().getServletRequest() if you want to work on “Servlet level”..

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 14:30


To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

It is not a webservice. In fact, it acts as a dispatcher. Depending on the parameters set received, it's goal is to redirect to a particular URL (among several possibilities) of the application (which is bound to a specific component: a proxy component that routes some of the parameters to a backend service).

As the configuration of this "dispatcher" is stored in JCR, and related to the application's sitemap, I've decided to implement it as a Hippo managed URL. Thus, this is a dedicated entry in the sitemap that uses a specific component.

 

I can't test your suggestion today (not working on this project), but I'll test it tomorrow before anything else and let you know if it solves my trouble...

 

Have a nice day

 

David

 

On Mon, Mar 11, 2013 at 1:47 PM, Wouter Danes <[hidden email]> wrote:

If your “service” is a kind of webservice, you might want to look into a REST mount / api for this?

Hippo supports Apache CXF out of the box, which should make things a lot easier.

What are you trying to accomplish?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 9:42
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi,

 

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

 

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

 

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

 

David

 

On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:

Hello,


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.


>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard


>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>

> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



 

--
David MARTIN
Ippon Technologies


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
David MARTIN
Ippon Technologies

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: How to get both querystring and form parameters?

david
Ok, here is the feedback.
I can now access the desired parameter, good! Thank you for that.
Due to the unpredictable parameters names and number (I mean, from my "dispatcher" component point of view, which only acts as a proxy and should not know too much about what the service behind him needs), it wasn't possible to use getPublicParameter().
But, reading the parameter map directly from the HttpServletRequest (throught getRequestContext().getServletRequest()) did the trick.

A good point, and now let's discover what is my next technical challenge :)

Thanks.

David


On Mon, Mar 11, 2013 at 2:51 PM, David Martin <[hidden email]> wrote:
Good to know. I'll add this tip to my check list for tomorrow.
Thanks

David


On Mon, Mar 11, 2013 at 2:33 PM, Wouter Danes <[hidden email]> wrote:

AFAIK, there’s request.getRequestContext().getServletRequest() if you want to work on “Servlet level”..

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 14:30


To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

It is not a webservice. In fact, it acts as a dispatcher. Depending on the parameters set received, it's goal is to redirect to a particular URL (among several possibilities) of the application (which is bound to a specific component: a proxy component that routes some of the parameters to a backend service).

As the configuration of this "dispatcher" is stored in JCR, and related to the application's sitemap, I've decided to implement it as a Hippo managed URL. Thus, this is a dedicated entry in the sitemap that uses a specific component.

 

I can't test your suggestion today (not working on this project), but I'll test it tomorrow before anything else and let you know if it solves my trouble...

 

Have a nice day

 

David

 

On Mon, Mar 11, 2013 at 1:47 PM, Wouter Danes <[hidden email]> wrote:

If your “service” is a kind of webservice, you might want to look into a REST mount / api for this?

Hippo supports Apache CXF out of the box, which should make things a lot easier.

What are you trying to accomplish?

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of David Martin
Sent: maandag 11 maart 2013 9:42
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] How to get both querystring and form parameters?

 

Hi,

 

Thanks for your feedback. I'll give Wouter's advice a try, it seems so easy that I'm rather ashamed for not having seen this before :)

 

Regarding the others suggestions (Michiel and Ard), unfortunately, I can't use any hst:actionURL like URL since my service is a public entry point that can't be dynamically created: some other users, outside the scope of Hippo, are accessing the service using a predetermined and immutable URL (in my example /site/myservice, but of course in production, there is no "site" as the site application root is bound to /) and kind of protocol (the one I've described above).

 

I'll get back to you as soon as tomorrow, with Wouter's suggestion live results :)

 

David

 

On Sun, Mar 10, 2013 at 8:33 PM, Ard Schrijvers <[hidden email]> wrote:

Hello,


On Fri, Mar 8, 2013 at 5:50 PM, David Martin <[hidden email]> wrote:

> Hi everyone,
>
> My need is rather special, maybe a little weird, but I have to deal with it
> (I have to respect a kind of protocol):
> I'm accessing an URL managed by Hippo through a GET or a POST request.
> Let's call this URL : /site/myservice
> This URL is defined in hst:sitemap and bound to a component which will do
> many cool things :)
>
> When accessing with a GET request, I don't have any problem... My URL is
> something like /site/myservice?PARAM1=AAA&PARAM2=BBBB
> When I'm accessing using a POST I have to add a new parameter (third one in
> my example, let's say PARAM3=CCC), but this time this parameter IS NOT added
> to the querystring, but as a regular form parameter... You can figure the
> whole thing as a HTML form like this :
>
> <form action="/site/myservice?PARAM1=AAA&PARAM2=BBB" method="post">

You should refrain from using /site explicitly in your urls : I assume
you do not want your URLs in production to all start with /site,
right? That is why you need to use hst:link, hst:renderURL,
hst:actionURL etc for links. For these links, you never specify the
contextpath. The HST will include the contextpath depending on
hst:showcontextpath property on hst:hst/hst:hosts = true | false. This
way, you can switch off contextpath in prod when httpd takes care of
/site part.


>    <input type="hidden" name="PARAM3" value="CCC" />
> </form>
>
>
> And this is where I'm stuck: This parameter isn't accessible from my
> component, using the HstRequest object... The parameters map only has the
> querystring parameters...

As explained above, you can better use hst:link or hst:actionURL to
create the link for action attr in form:

1) Use hst:link if your form should hit doBeforeRender method
2) Use hst:actionURL if your form should hit doAction (for example to
really modify data)

To include query queparameters in a hst:link you use hst:param tags.
These will be namespaced, such that in doBeforeRender the
hstRequest.getParameter("someParam") can be read, even though in the
queryString it is something like r1_r2_r1:someParam= foo. The r1_r2_r1
is the namespace of the component that will be able to read the
someParam parameter.

How, in your case, the PARAM3 is part of the form, which are
un-namespaced parameters. To read them in doAction method you can just
use hstRequest.getParameter("PARAM3"). However, to read them in
doBeforeRender you need to explicitly mention you want to fetch an
un-namespaced parameters, hence, as Wouter points out, use
getPublicRequestParameter.

If you do not want all the namespacing going on as explained in a
nutshell above, you can set in your hst-config.properties

parameter.namespace.ignored = true

Note that you then do loose some features that are supported through
parameter namespacing

Regards Ard


>
> Is there any trick to enable this? In a classic Java EE development such a
> mix is gracefully handled and all the parameters are accessible through the
> parameters map, but due to the way Hippo handle the request, that's not
> longer true in my particular case.
>
> Any help appreciated.
>
> Have a nice WE everyone.
>
> David
>
>

> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



 

--
David MARTIN
Ippon Technologies


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
David MARTIN
Ippon Technologies



--
David MARTIN
Ippon Technologies

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html