How can I trim this?

How can I trim this string?  
It has a space at the end.

<%
String username1 = (String)session.getAttribute("j_username");
%>
LVL 1
g118481Asked:
Who is Participating?
 
CEHJCommented:
You need to check for null

String username1 = (String)session.getAttribute("j_username");
if (username1 != null) {
    username1 = username1.trim();
}
      
      
0
 
Ajay-SinghCommented:
using trim() function should help:


String username1 = (String)session.getAttribute("j_username");
username1 = username1.trim();
0
 
g118481Author Commented:
Thank you.
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.