First off, you need to firm up those specifications.
1. What constitutes the 'right part' (the last slash and everything that follows it? a fixed number of characters?)
2. What constitutes the 'left part' (as many characters as can be accommodated? up to the last slash that can be accommodated?)
3. Depending on the first two specs, what's the fallback if the 'right part' and 'left part' together are too long to display?
4. In the event that dots are required, what's the minimum (and maybe maximum) number of dots? how are they to be grouped?
5. Does the solution have to cater to resizing of the Swing component used for display? With changing the LaF? With setting a different Font?
Whatever the spec, you'll want to look into
java.awt.font.TextLayout and its
getBounds() method.
Oh, and does this have anything at all to do with
JSP (
Java Server Pages)? Looks to me it would sit better in the GUI forum.