You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Franck Borel <bo...@ub.uni-freiburg.de> on 2007/09/26 15:28:12 UTC

Filter GET and POST

Hi,

i have a problem with an application that only accept GET requests. Now, I would 
like to know, if there is any possibility to write a filter, who is able to 
change the method from POST to GET.

I see that the FORM-Authentication could speek GET after authentication with 
POST method. Is there anybody outwhere, who knows how this was done?

-- Franck

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Filter GET and POST

Posted by Franck Borel <bo...@ub.uni-freiburg.de>.
Hi Christopher,

>>> I'm not sure why you'd want to do this, since
>>> servlets do not really distinguish between GET and POST parameters --
>>> the API abstracts that complexity away from your code.
>> If I change the request from POST to GET the Servlet works. I have no
>> possibility to change the Servlet behind.
> 
> When you say "does not work", what do you mean? What happens when you
> use POST?

I don't know if you know Shibboleth. This is the servlet (IdP = Identity
Provider) who lies behind. The servlet accepts only GET requests and brakes down
if I send him a POST request.

> It would be (somewhat) trivial to accept a POST request on one URL and
> then forward (or redirect, I suppose) to another URL with the POST
> parameters converted into GET parameters. It's up to you to find out if
> a filter can do this properly, or even if that's what you want to do.

I found a solution: I send the user back to the same address via sendRedirect. 
Now my filter works fine with the IdP behind. Thanks for your support!

-- Franck

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Filter GET and POST

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Franck,

Franck Borel wrote:
>> I'm not sure why you'd want to do this, since
>> servlets do not really distinguish between GET and POST parameters --
>> the API abstracts that complexity away from your code.
> 
> If I change the request from POST to GET the Servlet works. I have no
> possibility to change the Servlet behind.

When you say "does not work", what do you mean? What happens when you
use POST?

It would be (somewhat) trivial to accept a POST request on one URL and
then forward (or redirect, I suppose) to another URL with the POST
parameters converted into GET parameters. It's up to you to find out if
a filter can do this properly, or even if that's what you want to do.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+n089CaO5/Lv0PARAuPoAJoDFtsAN8ci9AT4pbHnZ4N+dukFXQCgoxix
VJGQrcvXxi23xpUcR/JSbJQ=
=B9Qg
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Filter GET and POST

Posted by Franck Borel <bo...@ub.uni-freiburg.de>.
Hi Christopher,

thank you very much for your answer.

>> i have a problem with an application that only accept GET requests. Now,
>> I would like to know, if there is any possibility to write a filter, who
>> is able to change the method from POST to GET.
> 
> What do you mean by that? Do you just want to change the return value of
> HttpServletRequest.getMethod? You can certainly do that easily.
No.
> Do you want to convert POST parameters to GET parameters? That is a bit
> tougher, but is possible. 
Yes, I think this is the only possibility. I found no example how this could be 
done. Any idea?

> I'm not sure why you'd want to do this, since
> servlets do not really distinguish between GET and POST parameters --
> the API abstracts that complexity away from your code.

If I change the request from POST to GET the Servlet works. I have no
possibility to change the Servlet behind.


>> I see that the FORM-Authentication could speek GET after authentication
>> with POST method. Is there anybody outwhere, who knows how this was done?
> Given that the Tomcat source code is available, you could always look in
> there for inspiration!

Thanks!

-- Franck

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Filter GET and POST

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Franck,

Franck Borel wrote:
> i have a problem with an application that only accept GET requests. Now,
> I would like to know, if there is any possibility to write a filter, who
> is able to change the method from POST to GET.

What do you mean by that? Do you just want to change the return value of
HttpServletRequest.getMethod? You can certainly do that easily.

Do you want to convert POST parameters to GET parameters? That is a bit
tougher, but is possible. I'm not sure why you'd want to do this, since
servlets do not really distinguish between GET and POST parameters --
the API abstracts that complexity away from your code.

> I see that the FORM-Authentication could speek GET after authentication
> with POST method. Is there anybody outwhere, who knows how this was done?

Given that the Tomcat source code is available, you could always look in
there for inspiration!

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+mbZ9CaO5/Lv0PARApC0AJ4mqO0C9Z35plJvEyE+JJ6zuybO7QCeILmO
a1/C4ydqfh8Ctgz1s5I0GWk=
=dNzE
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org