I am retrieving data with an SQL statment into a result set (string contains a pound sign), then I need to pass that value along to another jsp page (in the form of a value in a URL to an update page). When it gets to the new page it apparantly doesn't like the character. It doesn't display any characters from the pound sign to the end of the string or any other values in the URL string that come after that. I found some specification on the URL to change the pound sign to a percent23. If I type that value into the URL (percent23 in place of the pound sign) this works and will display the parameter correctly.
I have been trying to use the replace method once I get my field value from the result set and haven't been having any success. I tried using
String s = s.replace("\#", "\%23");
, and have gotten different error messages. Invalid character constant, invalid escape character, etc. depending on how I try to use the method. I even tried the
String s = s.replaceAll("\#","\%23");
, and that gives me a class not found exception error.
I am still fairly new to java and would appreciate any help. Thank you.