aspose file tools
The moose likes JSP and the fly likes Replace URL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Replace URL" Watch "Replace URL" New topic
Author

Replace URL

Devutty Pradeep
Greenhorn

Joined: Jan 21, 2003
Posts: 3
Hello,
I've a string with so many urls like "This string causes trouble http://www.abc.com and this also https://www.abc.com and this also www.xyz.com. Ive to display it as links in the page.How do i do that? Any inbuilt functions to do this?
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
use a <href =...> e.g.
... causes trouble <a href="http://www.abc.com">http://www.abc.com</a> and ...
hope this helps.
[ January 22, 2003: Message edited by: boyet silverio ]
Devutty Pradeep
Greenhorn

Joined: Jan 21, 2003
Posts: 3
Sorry I mean like this
String a = "This string causes trouble http://www.abc.com and this also https://www.abc.com and this also www.xyz.com.";
Ive to change it to
String b = "This string causes trouble <a href="http://www.abc.com">http://www.abc.com</a> and this also <a href="https://www.abc.com ">https://www.abc.com</a> and this also <a href="www.xyz.com">www.xyz.com</a>.
Any idea?
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
So you want to recognize certain patterns in a string and translate them to other patterns? This sounds like a job for java.util.regex !
First you will need to think about what distinguishes one of these patterns. How do you, as a reader, recognize them? Once you understand this, you can write it as a "regular expresion". The java.util.regex API has tools for doing just this sort of transformation.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Replace URL
 
Similar Threads
Redirecting The Request
struts url-pattern problem..
Replace URL
Connect jsp & mySQL Remotely
Connect jsp & mySQL Remotely