You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Karr, David" <Da...@wamu.net> on 2003/11/28 20:10:44 UTC
Clean way to analyze returned redirect URL from servlet
I'm using Cactus 1.4.1, Tomcat 4.1.24, and JDK 1.4.2.
I have a servlet whose main purpose is to return a redirection URL which
contains several query parameters. In my test, I'd like to verify that
the query string contains certain request parameters, with certain
values. However, I don't think it's a good idea to assume the order of
those parameters, because they wouldn't affect the operation of the
servlet.
Currently, in my "end" method, I pull the URL out of the "location"
header, and get the query string from that. What is a reasonable
strategy for post-processing the returned redirection URL so I can
robustly parse it and verify the values? I could easily make some
guesses, like a StringTokenizer for "&", but I'm wondering if that's the
correct way to do this.
RE: Clean way to analyze returned redirect URL from servlet
Posted by Vincent Massol <vm...@pivolis.com>.
> -----Original Message-----
> From: Karr, David [mailto:David.Karr@wamu.net]
> Sent: 28 November 2003 20:11
> To: cactus-user@jakarta.apache.org
> Subject: Clean way to analyze returned redirect URL from servlet
>
> I'm using Cactus 1.4.1, Tomcat 4.1.24, and JDK 1.4.2.
>
> I have a servlet whose main purpose is to return a redirection URL
which
> contains several query parameters. In my test, I'd like to verify
that
> the query string contains certain request parameters, with certain
> values. However, I don't think it's a good idea to assume the order
of
> those parameters, because they wouldn't affect the operation of the
> servlet.
>
> Currently, in my "end" method, I pull the URL out of the "location"
> header, and get the query string from that. What is a reasonable
> strategy for post-processing the returned redirection URL so I can
> robustly parse it and verify the values? I could easily make some
> guesses, like a StringTokenizer for "&", but I'm wondering if that's
the
> correct way to do this.
Yes, that's the correct way. 2 string tokenizers, one for "&" and one
for "=" and put the extracted values in a Map. Then you can perform easy
assertions.
-Vincent