i have a link http://localhost:8080/reporting/pvsUsageAction.do?form_action=inline_audit_view&days=7&projectStatus=scheduled&justificationId=5&justificationName= No Technicians in Area
in my struts based web application.
The variable in URL justificationName
have some spaces before its vales as shown. when i get value of justificationName
using request.getParameter("justificationName")
it gives me that value with spaces as given in the URL. i want to remove those spaces. i tried trim()
i tries str = str.replace(" ", "");
but any of them did not removed those spaces. can any one tell some other way to remove the space.
Noted one more thing that i did right click on the link and opened the link into new tab there i noticed that link looks like.
http://localhost:8080/reporting/pvsUsageAction.do?form_action=inline_audit_view&days=7&projectStatus=scheduled&justificationId=5&justificationName=%A0%A0%A0%A0%A0%A0%A0%A0No%20Technicians%20in%20Area
Notable point is that in the address bar it shows %A0
for white spaces and also show %20
for space as well see the link and tell the difference please if any one have idea about it.
EDIT Here is my code
String justificationCode = "";
if (request.getParameter("justificationName") != null) {
justificationCode = request.getParameter("justificationName");
}
justificationCode = justificationCode.replace(" ", "");
Note: replace function remove the space from inside the string but not removing starting spaces. e-g if my string is " This is string" after using replace it becomes " Thisisstring"
Thanks in advance