reset password
Author Message
Vanquish39
Posts: 134
Posted 15:03 Apr 07, 2011 |

When I send C++ as a parameter to another servlet, it gets returned as "C".  I replaced the ++ with another special character such as &cent, so when I pass it into the other servlet, I can replace it, but no luck. 


Instead of passing C++ i'm passing C&cent&cent.

The other servlet receives it as C&cent&cent, but when I try to replace &cent with +, it doesn't work.  Any idea?

cysun
Posts: 2935
Posted 15:28 Apr 07, 2011 |

+ is interpreted as white space in a query string, and + itself becomes %2B (see URL Encoding).

On the client side, if you use a form to submit the parameters, the browser will automatically do the encoding; if you manually code the parameters in a URL, you have to do the encoding yourself.

On the server side, the parameters will be decoded automatically by the application server so you don't need to do substring replacement (note that this is different from the special character filtering we discussed in class).

dely
Posts: 32
Posted 22:50 Apr 07, 2011 |

Try googling "url encoding java" ;)