wood burning stoves*
The moose likes Beginning Java and the fly likes String/Character Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String/Character Problem" Watch "String/Character Problem" New topic
Author

String/Character Problem

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I have some code on a JSP page but it is purely a java problem that I am having...
Here is the code...
String URL = request.getParameter("URL");
String newURL = request.getParameter("URL") + "?";
String addOn = request.getParameter("instructions");
for (int i = 0; i!=addOn.length(); i++)
{
if (addOn.charAt(i)==(' '))
out.print("DDDDDDDDDDD");//newURL = newURL + "&";
else
newURL = newURL + addOn.charAt(i);
out.print(addOn.charAt(i) + "<br>");
}
out.println("<br>" + request.getParameter("instructions"));
********************************
addOn.charAt(i)==(' '))
This method does not recognize my blanks.... Is there a better way?
Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
I am not good at strings but still try this
String someVariable=" ";
for (int i = 0; i!=addOn.length(); i++)
{
someVariable = addOn.charAt(i);
if (someVariable.equals(""))
out.print("DDDDDDDDDDD");//newURL = newURL + "&";
else
newURL = newURL + someVariable;
out.print(someVariable + "<br>");
}
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Try using the char assignment. Space is a 32


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: String/Character Problem