• Post Reply Bookmark Topic Watch Topic
  • New Topic

HTML and Java  RSS feed

 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to mix HTML with java when creating an application? For example I make a java browser like thing for the HTML and I use the HTML to create the interface only. Everything else is Java. For example I want to the text boxes, buttons, links, etc in HTML. But everything is processed and stored using Java.

If this is possible, I'd appreciate it if anyone can point to any tutorials or articles.

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be describing JavaServer Pages. Check out the link, then come back here and let us know if you mean something different.
 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well,not really. I dont know how to code JSP. Is it quite similar to Java? I was thinking more like how to communicate between the HTML text boxes etc, with Java code. Maybe using JavaScript? I'm trying to create something which is mainly built on Java but HTML components are just used on the UI for decoravtive purposes.

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSP, you mix Java and HTML in one file; the Java runs on the server, and generates parts of the page. By the time the page is in the browser, the Java has already run and is gone. So that's not what you want.

What you want instead is indeed JavaScript, not Java. JavaScript is a scripting language, completely separate from Java, that can be embedded in HTML and runs in the web browser, and behaves as you describe. The similarity in names is due only to an idea by some marketing guy.
 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is it possible to use it with Java? I mean by creating the interface using JavaScript and HTML and using Java to perform the operations? Also displaying the required page like panels using JButtons?
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and no.

JavaScript can be used for the front end, but all Java processing happens on the server, so it's not possible to have the Java run as part of the web page. Since the display is handled by HTML/JavaScript, you only have the display options that HTML/JavaScript supports (No panels, no XY co-ordinates, etc.)

You do have a few options; however. An Applet could do what you want (it gives you the layout capabilities and Java support), but it is longer to download and large-scale use is frowned upon. Flash components have a smaller footprint and you can do nice layout with them, but communication with the Java code can get a little tricky. (Your Java code on the server really should be set up as web services to support the Flash front end.)
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the end, of course, anything is possible. What you should really be asking is what's easy, accepted, standard, supported. What you're specifically asking about (tightly integrated Java and HTML all running on the client) is none of these things; it's just not what people do. If your application is running locally -- i.e., it's software that people have to install on their desktop -- then you'd use 100% Java, making the GUI with Swing, or similar. If it's a Web-based app, then you'd use HTML and JavaScript on the client, and Java on the server. The client JavaScript can send various requests to Java code running on the server, but it's not the sort of tightly coupled interaction you're talking about.

So, if you're still with me: tell me why you wanted to do this in the first place? Maybe I could tell you a better way to achieve the same goal.
 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you're specifically asking about (tightly integrated Java and HTML all running on the client)


This exactly what I want to do The reason is, I want create a nice looking GUI with links instead of buttons except for functions like "Submit" etc.

Heres an article which talks about hyperlinks in JEditorPane.
Article

Is it worth it for me to try it or would it be too troublesome? (I'm still learning Java )

Thanks again for the replies
 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres a program that uses hyperlinks and I think its kinda cool.

Program
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. OK, sure. Now I see what you're interested in doing.

Yes, JEditorPane lets you display HTML in an application. But if what you're interested in is just the links part as shown in the screenshot, you can actually do that easily enough with a JButton by hiding the borders and giving it appropriate mouse-over behavior. I wouldn't try to build the whole GUI as HTML just to stick it in a JEditorPane. You'd kill yourself trying to make it look halfway decent.
 
Darrell Morello
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is there anyway I can create a rollover effect on the button text without using an image? I use Netbeans and I couldnt find any such thing from it.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!