Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert String URL to render as html link

807606Apr 2 2007 — edited Apr 3 2007
HI there,
I have a bean property 'theDescription' which represents some text submitted by users that I am retrieving from a database. The problem I have is that some submissions contain a URL address within the text...at times very long URL's. It's simple enough to extract the URL using the snippet below:
 public static void main(String args[]) {

        String theDescription = "some comments http://someurl.com some more comments";
        String theURL = "";
      
        Pattern pattern = Pattern.compile("http(.+?)\\s");
        Matcher matcher = pattern.matcher(theDescription);

        while (matcher.find()) theURL = matcher.group();

        System.out.println(theURL);
    }
What i need to do is some how display the selected text as a link when my JSF page is rendered.

So ideally it would show as:

some comments Link some more comments

thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2007
Added on Apr 2 2007
6 comments
873 views