• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with URLEncoding  RSS feed

 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I've got a setup where I have an applet that is sending queries (Strings) to a servlet which runs the queries and sends the results back to the applet. I URLEncode the query string before sending it, then when I URLDecode it on the servlet end I run into a problem with joins where the sql syntax is "(+)". Decoding the string converts the "+" to a white space. Anybody Know how to handle this situation??
Thanx
Dave
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, spaces are converted to plusses when you encode the url ... so, if you have some sql statment in there that needs the +, you're going to need to encode that first.
So, something like
String sql = "blah + blah and more blah";
String response = sendToServlet(sql.convertPlusses().urlEncode();

on the servlet ...
String sql = queryString;
doQuery(sql.urlUnEncode().unconvertPlusses();
and on and on.
OR, you can post POST it to the servlet, which would only have to retrieve the parameter and not have to deal with the url encoding.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You Sir, are a smart fellow
leave out that one little detail
connection.setRequestMethod("POST");
and you can create all kinds of problems for youself
Thanx
Dave
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smart fellow, huh? Little ol' me? I don't suppose you could forward that post down the hall to your favorite HR rep, eh? :roll:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!