This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Regarding ActionContext.getContext().getParameters(); is struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Regarding ActionContext.getContext().getParameters(); is struts2" Watch "Regarding ActionContext.getContext().getParameters(); is struts2" New topic
Author

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

kajal mukergi
Ranch Hand

Joined: Mar 22, 2007
Posts: 102
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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 +


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
kajal mukergi
Ranch Hand

Joined: Mar 22, 2007
Posts: 102
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Mar 22, 2007
Posts: 102
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Mar 22, 2007
Posts: 102
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Mar 22, 2007
Posts: 102
Ok friend
thanks you very much for your analysis
It was really very helpful for me.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding ActionContext.getContext().getParameters(); is struts2
 
Similar Threads
session in Strut2
how to set the request Session in Strut2
request.getParameter in struts2
remove session data
How to get Iterating value in a list of VO struts2