Hi. I have a JSP page and I'm having trouble with some parameters... The page has a form containing a listbox, something like...

<select name="listnames" MULTIPLE>

Files are browsed for with a <input type=file> object, when this is changed (onChange) the value is added to the listbox.
When the form is submitted with submit() -- all the selected options are then passed as parameters e.g. page.jsp?listnames=name+1&listnames=name+2
Here's the problem. Once submit I want to keep these values in the select box once its reloaded. So how I've done that is, for each 'listnames' paramater, an option is made when its reloaded
e.g.
for each filelist parameter...

<OPTION NAME=<%=parametername%> VALUE=<%=parametername%>><%=parametername%></OPTION>

Once the page is submit again, the spaces have now been removed. Where once there was 'name 1' which appears as 'listnames=name+1' on the parameters, it is now just 'name' when re-submitted. There seems to be a problem with the spaces being recognised the second time round!! Does any one have any ideas how to resolve this?
Thanks alot

Without further investigation I can't promise that I am the right track here... But it may be in the url encode and url decode that is taking place... the "+" is the encoded space " " the first time, but the second time, it would get url encoded AGAIN... double encoding.... but the second time it would be encoding "+" as if it thought a "+" belongs in the name.... This double encoding can cause these kinds of troubles when the data actually reaches the server...

I ran many localization projects a few years back for a major software company. Since we were localizing the application for Asian countries MOST text gets encoded... But they too ran into situations where double encoding took place... and it led to similar problems... They had to double decode the text for Asian versions to make it work right...
You could un-encode it prior to placing it in your second form.... so that it would be value="name 1"

I also suggest you use quotes around your parameters... your example doesn't, but you may be actually doing it, I don't know, but just in case... because if you don't use quotes and your problem is just the opposite, the spaces ARE decoded before going in your second form.... then you have effectively
value=name 1
and without quotes the browser will see the space as the END of the parameter value and treat the 1 as an unknown parameter... unknown parameters, by the standard are simply ignored....

So those are 2 possible place to start looking...

If you have any more information feel free to follow-up and I will always see what help I can provide...

Peace,

This article has been dead for over six months. Start a new discussion instead.