Okay heres the problem

i have stored Phone numbers from a check box into an array

i want to replace #NUMBERS# in the String URL with a value from the array numbers[]

example :

number[1] = 0000
Before:
url:http://www.sendmessgae.com/send?#NUMBERS
After:
url:http://www.sendmessgae.com/send?0000

String url = "http://www.sendmessgae.com/send?#NUMBERS"
for (int i = 0; i < numbers.length; i++)
{
String expression = "#NUMBER#";
String replacement = String numbers[i];

String URL = URL.replace(expression, replacement);
}

response.sendRedirect(URL);

The above code is what i have so far however it is not working
i was wondering if any one could assist me in getting it working as i am fairly new to jsp and java.

Thanks in advanced

Hello,

Use RequestDispatcher() and forward(), instead of sendRedirect().

Forwarding is not so very different from request redirection (Servlet Request.sendRedirect()). However, forwarding has an advantage—the request information (parameters and attributes) are preserved.

Hope it helps.

THis will replace #NUMBER with the array of number. But take care if there are more than one "#NUMBER" in your url. If such condition comes than u have to replace all #Number with good care.

String url = "http://www.sendmessgae.com/send?#NUMBERS"
StringBuffer replacement = new StringBuffer() ;
for (int i = 0; i < numbers.length; i++)
{
   replacement = replacement.append(nember[i]);
}
url = url.replaceAll( "#NUMBER", replacement );
response.sendRedirect(URL);
This question has already been answered. Start a new discussion instead.