1

I am working on a project which is basically a Java application with an embedded IE browser (using JDIC 0.9.5) to display custom HTML files (stored locally that I created). I have a test HTML file with a JavaScript function that checks a simple form with checkboxes and alerts the user with a dialog stating which checkboxes are checked.

My question is, is there a way for my Java application to do the same procedure on the embedded HTML form instead of using JavaScript. I want to keep my application and HTML files simple without the clutter of JavaScript in my HTMLs or a pile of .js files. Thanks for any help and guidance!

4 Answers 4

1

You have two options. Either shift the project to run the Java on the server side using JSP technology inside a web container like Apache Tomcat or Jetty, or write you web page to open up a Java applet.

The applet route allows you to run the code on someone else's machine, and as a trade off you will have to run the application in a strongly security constrained environment. After all, if someone were to run code on your machine, you wouldn't want it able to access your disk, etc.

The JSP solution will have you running the code on the same machine as your web server, since you (probably) control your own web server, the code will not be ran with as many security constraints enabled. This means the code can make requests to other machines, write and read files, etc.

Sign up to request clarification or add additional context in comments.

1 Comment

Cool thanks Edwin, I am not too far along with project, so I'll have to spec out JSP and see if it fits my project needs, I appreciate your feedback :)
0

You could replace your model with a client-server model using Java Server Pages (JSP).

1 Comment

Thanks mcandre, JSP looks like where I will be heading to further this project
0

If you are displaying the page through an embedded browser it is very unlikely that you will be able to get access to the DOM via Java.

One option is to use GWT javascript compiler to code in java and then convert to javascript. If it will only use IE, then you will only need to keep one of the generated .js files, so the clutter will be low.

1 Comment

Thanks bashflyng, I'd figured it was gonna be a difficult task, so it never hurts to ask lol
0

Since you're embedding your HTML files in your own Java program, I would recommend you to use one of these 2 approaches:

1.- Use Javascript and structure the files cleanly, is not that complex.

2.- When you do the POST check the values in your Java code and return a new dynamically generated HTML file with needed info

I sincerely recommend you to follow the first option. Other options to work with Java in HTML would be JSP or GWT, but both will require a proper J2EE server, which would be overkill in your application

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.