在嵌入式HTML而不是JavaScript上使用Java代码? [英] Using Java code on embedded HTML instead of JavaScript?

查看:203
本文介绍了在嵌入式HTML而不是JavaScript上使用Java代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,该项目基本上是一个带有嵌入式IE浏览器(使用JDIC 0.9.5)的Java应用程序来显示自定义HTML文件(本地存储的)。我有一个带有JavaScript函数的测试HTML文件,它用复选框检查一个简单的表单,并通过一个对话框提醒用户检查复选框。

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.

我的问题是,是有一种方法可以让我的Java应用程序在嵌入式HTML表单上执行相同的过程,而不是使用JavaScript。我想保持我的应用程序和HTML文件的简单,而不会在我的HTML或一堆.js文件中出现混乱的JavaScript。
感谢您的帮助和指导!

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!

推荐答案

您有两种选择。将项目转移到在Apache Tomcat或Jetty等Web容器中使用JSP技术在服务器端运行Java,或者写入网页以打开Java小程序。

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.

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.

JSP解决方案将让你运行代码与您的Web服务器位于同一台计算机上,因为您(可能)控制了您自己的Web服务器,所以代码将不会与启用的安全限制一起运行。这意味着代码可以向其他机器发送请求,写入和读取文件等。

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.

这篇关于在嵌入式HTML而不是JavaScript上使用Java代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆