Displaying a user belt rank on your site
We provide support for displaying the belt rank of JavaBlackBelt users on your site. It's easy and free.
|
Who displays JavaBlackBelt ranks ?
Individuals on their blogsYou have your own website, which is for example a blog. You may want to display your current belt rank to your audiance. |
CommunitiesSome community sites are going to display the belt ranks for their users who have also an account on JavaBlackBelt. This is the case of Javalobby.org, for example. |
How?
We provide a Web Service that enable you get the rank of a user, from either: 1- a JavaBlackBelt user nickname,2- your user id/name (and we find the matching JavaBlackBelt user) The first case is very simple. It is typically used by individuals who want to display their belt on their website/blog. The second case is very easy for communities, because we hold the match between their user id and our user id in our DB.
For example, on JavaBlackBelt, a user can set his Javalobby name if he wants his belt to be displayed on Javalobby. When Javalobby wants to display this user's belt, it calls our web service, giving it the user Javalobby's name. In the answer, we tell Javalobby if we have a matching user (with his belt rank) or not.
If a community prefers us not to store their user name, but prefer them to store the JavaBlackBelt name, it is also possible. They call our web service with the JavaBlackBelt name. It's just more work for them (add a JavaBlackBelt field in their user table). If you use Java for your website, your work is facilitated by client Java classes we provide. It's powerful (with caching for example) and very easy to use as explained below.
How to access the web service using our Java client classes ?
We provide a jar file containing the UserBeltService class (and other classes used by it, which you don't need to be aware of). You typically call this method from your JSP:
public String getBeltImgUrl(String userName);
and get the url to the correct belt picture to be displayed.
We provide caching (that you can configure), so a second call with the same user (page redisplay for example) will not call the web service again.
![]() |
See detailed information and examples |
How to access the web service using our JavaScript classes ?
You may not have the possibility to call server-side Java code. For example, sites hosted a apache.org typically use static html for their content. This is a perfect example where you would use a small JavaScript function to contact our web service from the browser and get the user information to be displayed. Obviously, with this configuration you cannot provide server-side (your server) caching, and the belt will not be displayed for visitors disabling JavaScript on their browser. To display a belt <table><tr>
<td>
<script src="http://www.javablackbelt.com/js/jbb_userbelt.js" type="text/javascript">
</script>
<script type="text/javascript" defer="defer">
jbb_userbelt_size= "medium";
jbb_usernames = "jube";
displayBelt();
</script>
</td>
<td>
<script src="http://www.javablackbelt.com/js/jbb_userbelt.js" type="text/javascript">
</script>
<script type="text/javascript">
jbb_userbelt_size= "small";
jbb_usernames = "jube";
displayBelt();
</script>
</td>
<td>
<script src="http://www.javablackbelt.com/js/jbb_userbelt.js" type="text/javascript">
</script>
<script type="text/javascript">
jbb_userbelt_size= "large";
jbb_usernames = "jube";
displayBelt();
</script>
</td>
</tr>
</table>
The result is:
To display a list of user ( like congratulations list)
<script src="http://www.javablackbelt.com/js/jbb_userbelt.js" type="text/javascript"></script>
<script type="text/javascript" >
jbb_usernames = "jube,xjamin";
</script>
The result is:
How to access the web service using another language ?
From the Java and JavaScript examples above and from your language documentation, it should be easy for you to figure how to use our web service from another language (as PhP).Please contact us if you want to extend this documentation page with additional examples from you.

