• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding ActionContext.getContext().getParameters(); is struts2

 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends

i have url http://localhost:9090/mysite.com&somapp=encryptedurl?id=NmpnO2gpgSi+FvZHIvRza

opened in the browser.

when i say ActionContext.getContext().getParameters();

i am getting Map of these values like below.

Map params = ActionContext.getContext().getParameters();

the issues is the '+' character in NmpnO2gpgSi+FvZHIvRza

is being replace with space. So in the code i am getting the same value as NmpnO2gpgSi FvZHIvRza(+ is replace with ' ')

which is big blunder for my application. javascript:emoticon('');

can anyone please help me out.

Please URGENT



 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kajal mukergi wrote:the issues is the '+' character in NmpnO2gpgSi+FvZHIvRza

is being replace with space. So in the code i am getting the same value as NmpnO2gpgSi FvZHIvRza(+ is replace with ' ')

This is what w3schools says:
URLs cannot contain spaces. URL encoding normally replaces a space with a + sign

And URL code for "+" is %2B, use this instead of +
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much friend.
Really very much helpfull.

But is there any other way we can retrieve the url as it is.

since this url is getting from 3rd party..


 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kajal mukergi wrote:since this url is getting from 3rd party..

I do not know how they are sending that URL, but you can anytime replace that 'space' with + sign , as you know that space means '+',
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya we can do that but

we can't be sure that every space will be 100% + character.
There may be chance that

any other character can be replace with "space"

 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I got it now:

Some one sends you the URL, with space in between:
http://localhost:9090/mysite.com&somapp=encryptedurl?id=NmpnO2gpgSi FvZHIvRza

Now, you run that URL in browser and browser encode that url with "+" sign as space is there, like:
http://localhost:9090/mysite.com&somapp=encryptedurl?id=NmpnO2gpgSi+FvZHIvRza

And in Action you gets, value with the space, which is the original value set into the URL, so no need to worry Don't add "+" to it...
You're getting right value.
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No yaar.

It is other way round of what you said ,

I am getting + and in action is retrieved as space..


i am saying that.. is there any other chance of any other element being .. retrieved as space in ACTION

if not i can implement your solution. that is replace space with + character
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kajal mukergi wrote:I am getting + and in action is retrieved as space..

i am saying that.. is there any other chance of any other element being .. retrieved as space in ACTION

OK, as far as my knowledge is cocerned, there is no chance of getting space other than for chracter "+", still to make sure our assumption, why don't you request them to send you an URL which contain ' ' space in between, and then you can see what you get for that
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok friend
thanks you very much for your analysis
It was really very helpful for me.
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic