Results 1 to 8 of 8
  1. #1
    Nicolai is offline Member
    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Default Embedding browser functionality in a Java application

    Hi.

    I'm your standard newbie in all sense. So you'll have to forgive me if this is the wrong forum to post this thread. Please advice me if it is so.

    I have a question regarding how to embed browser functionality into a Java application.

    Is there any way to create a java application that can report to a embedded web browser (e.g. firefox). Lets say that you have an application that retrieves info from a db and you what to have that info displayed in a browser like window, using e.g. css as a formatting tool.

    So my questions are:

    1. Can you embed e.g. firefox browser into an application?
    2. Can you format the output from the application with css (or other forms of formatting)?
    3. Would xml be a good candidate for data transport between the application and the browser/display window?


    Hope you can shed a little light on these matters. If you could point to excisting project that would be a great help.

    Thank you for your help in advance.

    Nicolai

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    1)What do you mean by "embed? Would starting the browser in its own process in a java app be considered embedding?
    2)How are you generating the output? Is the java app supposed to read a file with css and format it? I don't think that is part of native java.
    3) What do you mean by "data transport"? Would writing a disk file to be read by the browser be data transport? It would be one time thing done before the browser was started.
    Another way that I've used is to have the java app be a HTTP server that starts the browser and communicates with the browser via a Socket using HTTP protcol.
    See following for example:
    http://shellknob2007.googlepages.com...rverSource.zip

  3. #3
    Nicolai is offline Member
    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Default

    Hi.

    First of all i'd like to thank you for your reply. I'll try to elucidate what I mean.

    1)What do you mean by "embed? Would starting the browser in its own process in a java app be considered embedding?

    I have an application using the Java html generator (i think). It is very limited in generating html-pages regarding fonts, formatting a.s.o. I was wondering if you could use e.g. the mozilla browser engine to be the rendering machine. By embedding I was thinking about having a window in my application that uses e.g. the mozilla engine and not the java html generator.


    2)How are you generating the output? Is the java app supposed to read a file with css and format it? I don't think that is part of native java.

    The output are governed by SQL statements retrieving info from an Oracle database. Here tags for font, formatting is added before send to either the html-geberator or the rtf-generator. It is either converted to rtf for paper prints or to html for on screen display. I was thinking that you could use only of type of outputs (html) reading a CSS-file (maybe) for formatting and then generate the html (both for prints and for screen display)


    3) What do you mean by "data transport"? Would writing a disk file to be read by the browser be data transport? It would be one time thing done before the browser was started.

    One could write to a temporary file that the browser should read using css-formatting (if this is possible). The browser should/could be started at the start of the application.

    I hope I make make myself remotely understandable.

    Nicolai

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Post some suggestions

    Quote Originally Posted by Nicolai View Post
    I have an application using the Java html generator (i think). It is very limited in generating html-pages regarding fonts, formatting a.s.o. I was wondering if you could use e.g. the mozilla browser engine to be the rendering machine. By embedding I was thinking about having a window in my application that uses e.g. the mozilla engine and not the java html generator.
    Java is embedded in Mozilla, usually it is simpler to use the Java HTML Editor Kit which, as you say, has limited capabilities. You make an interesting point; Java is nativily network-centric but the 'browser' is remarkably limited.

    Quote Originally Posted by Nicolai View Post
    The output are governed by SQL statements retrieving info from an Oracle database. Here tags for font, formatting is added before send to either the html-geberator or the rtf-generator. It is either converted to rtf for paper prints or to html for on screen display. I was thinking that you could use only of type of outputs (html) reading a CSS-file (maybe) for formatting and then generate the html (both for prints and for screen display)
    I am working on a not-dissimilar effort this morning. Trying to achieve formatted printing could be done by writing rtf, but that format seems to have been largely replaced with various flavors of xml - for which there are several engines already written in Java or being devleoped as fast as people can write them. Seems to me xml in it's various incantations is very popular in Java right now, though which editor kit to use would have to be researched.

    Quote Originally Posted by Nicolai View Post
    One could write to a temporary file that the browser should read using css-formatting (if this is possible). The browser should/could be started at the start of the application.
    Memory resident files are well established in Java, maybe some of the Java genius we have around here can identifiy something in the swing classes we can begin with.

    We have no shortage of gurus, your question is well worded.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    The simplest solution (too simple???) would be for the java program to create a disk file containing the HTML, CSS etc and start a browser to read and display that file. With this scheme, there is no interaction between the java app and the browser other than that the file read by the browser was written by the java app.
    To start the browser after the file was written you would use the Process and Runtime classes.

  6. #6
    Nicolai is offline Member
    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Default

    Hi all.

    Thanks alot for your answers.

    Isn't the simplest solutions often the best???

    I think that the solutions Norm highlights could be a nice solution.

    I was just thinking how you could have this browser be an integrated part of the java-application then?

    But most striking is the lack of support for rich formatting towards showing content in html form.

    Thanks again.

    Nicolai

  7. #7
    Nicolai is offline Member
    Join Date
    Sep 2008
    Posts
    4
    Rep Power
    0

    Default

    Hi again.

    Getting back to issue about web browser.

    Which browser would be a good choice? Would JxBrowser be a good choice?

    Nicolai

  8. #8
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Excellent, really excellent.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Similar Threads

  1. Implement Search Functionality
    By New2484 in forum New To Java
    Replies: 2
    Last Post: 08-27-2008, 08:07 AM
  2. Functionality of Buttons
    By ljk8950 in forum AWT / Swing
    Replies: 6
    Last Post: 08-15-2008, 02:44 PM
  3. Embedding Word in an applet
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 03:34 PM
  4. Replies: 0
    Last Post: 06-24-2008, 12:16 AM
  5. Change Password Functionality
    By Priyadharshini.s in forum Advanced Java
    Replies: 5
    Last Post: 04-02-2008, 01:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •