Meaningless Drivel is fun!
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

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 + "&";
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 + "&";
newURL = newURL + someVariable;
out.print(someVariable + "<br>");
Cindy Glass
"The Hood"

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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: String/Character Problem
It's not a secret anymore!