How to pass parameterized String values to url rewrite filter?

18 views
Skip to first unread message

sirisha

unread,
Jun 25, 2009, 3:05:15 AM6/25/09
to UrlRewrite
How to pass parameterized String values to url rewrite filter?

I will give you a scenario :

In jsp I have an Hash map having

blogMap1.put(StringConstants.TOTAL_RECORDS,fm.getTotalRecords());
blogMap1.put(StringConstants.PAGE_NUM,fm.getPageNum());
blogMap1.put(StringConstants.QUERY_ID,fm.getQueryId());

pageContext.setAttribute("parameters1", blogMap1);

and Im using this map in <html:link> as

<html:link forward="<%= ForwardConstants.BLOG_EDIT_ACTION %>"
name="parameters1" scope="page" styleClass="edit_link">Edit</
html:link>

here i need a url having parameters in sequence as I have put in Hash
map.(but in my case these values are swaping for every time,this is
because of Hash map if I am correct).
I also tried with Linked Hash Map , but it didn't work.

At last what I need is , The parameters taken by the url rewrite
filter should be in the order which I have specified in hash map or
linked hash map.(the order should not be changed).

can anyone please help in resolving this issue...............

Avlesh Singh

unread,
Jun 25, 2009, 6:38:14 AM6/25/09
to urlre...@googlegroups.com
First of all, I am not sure why this is a url-rewrite question?

Second, if a LinkedHashMap does not work for you (in preserving order of the parameters in the URL), ask this question on the Struts user mailing list. I tried your use case, with a HashMap and a LinkedHashMap on my box (with struts 1.2.7) and it just works fine (and as expected) for me.

Third, your statement


The parameters taken by the url rewrite filter should be in the order which I have specified in hash map or linked hash map

did not make sense to me. Maybe, I am missing something.

Cheers
Avlesh

Wim De Smet

unread,
Jun 26, 2009, 4:28:04 AM6/26/09
to urlre...@googlegroups.com
I _think_ it might be the following problem: when you write a regexp
based rule query parameters tend to be really hard to parse as they
can shift around. Doing so in the rewrite rule is really not
recommended.

i.e.:
blah/query?var1=foo&var2=bar
blah/query?var2=bar&var1=foo
Do the same thing, but right now I don't really see a straightforward
way to get a working rewrite rule that parses both. There's probably
some regex voodoo you can do or just make two rules, but then the
amount of rules you need would be, er, strongly rising. (binomial?
haven't had much coffee yet today)

regards,
Wim
Reply all
Reply to author
Forward
0 new messages