Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Handling URL protocols in JEditorPane?

Thread view: 
Frank D. Greco - 26 Feb 2007 04:54 GMT
I have a simple JEditorPane that displays a very simple web page that has an
embedded "mailto:foo@bar.com"

When the user clicks on this link, I'd like the "usual" thing to happen:  the
native email program is invoked to compose an email with the 'To:' line filled
out.

At this point, I don't want to send email directly from my Java app (ie, with
JavaMail).  I need to use the native email program, which for my user is MS
Exchange.

I can get the link text when the user clicks on the mailto link, but I'm having
trouble invoking the native email program a la the typical browser.

Any help is appreciated.

Frank
Filip Larsen - 26 Feb 2007 09:15 GMT
> I have a simple JEditorPane that displays a very simple web page that
> has an embedded "mailto:foo@bar.com" [...] I can get the link text
> when the user clicks on the mailto link, but I'm having trouble
> invoking the native email program a la the typical browser.

I believe you should let the platform handle URL just like if it was a
http URL, so in an applet you would invoke
java.applet.AppletContext.showDocument,
in a WebStart application you would invoke
javax.jnlp.BasicService.showDocument, and in a stand-alone application
you would (still unfortunately, I believe) have to invoke some
platform-specific
command via java.lang.Runtime.exec in order to get the platform to
handle the URL. On Windows that would be something like "cmd.exe /c
start description mailto:foo@bar.com".

Regards,
Signature

Filip Larsen

Andrew Thompson - 26 Feb 2007 12:15 GMT
..
> > ...having trouble
> > invoking the native email program a la the typical browser.
>
> I believe you should let the platform handle URL just like if it was a
> http URL, so in an applet you would invoke
> java.applet.AppletContext.showDocument,

Unfortunately, showDocument() was never
reliable, and becomes less so as time
goes by.

> in a WebStart application you would invoke
> javax.jnlp.BasicService.showDocument,

Which at least returns a true/false to
indicate success/failure.  It is the
method I prefer to use (easy to do, when
most of my apps. are web start based!).

>..and in a stand-alone application
> you would (still unfortunately, I believe) have to invoke some
> platform-specific
> command via java.lang.Runtime.exec in order to get the platform to
> handle the URL. On Windows that would be something like "cmd.exe /c
> start description mailto:f...@bar.com".

For that (or a signed applet) I would
look to BrowserLauncher2, which takes a
rigorous approach to finding and launching
the (hopefully) default browser.

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.