GlassFish 3.0.1 服务器上的 Java 小程序
我开发了一个小程序,我正在使用JSP来上传它。我已经使用 Netbeans 6.9 进行了工作。小程序无需 JSP 即可正常工作。当我在 Glassfish 服务器上运行 JSP 时,小程序不运行。
我的小程序需要 43 秒来进行处理并显示,我认为这可能是问题所在。
当我使用相同的小程序运行相同的 JSP 但稍加修改时,小程序可以与 JSP 一起正确运行。修改是我注释掉了一个函数调用(从 init()
方法调用),该调用负责较长的执行时间。长时间运行的方法读取三个文件并在选择按钮中生成输出,即生成选择。
但我的小程序中需要该功能,这是非常重要的功能。
每个 catch 语句中都有一个 printstacktrace()
方法调用。
public void start(){
initialise_maps();
}
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable()
{
public void run() {
initComponents();
}
});
} catch (Exception ex)
{
ex.printStackTrace();
}
// initialise_maps();
}
I have developed an applet and I am using a JSP to upload it. I have worked it using Netbeans 6.9. The applet works fine without JSP. When I run JSP on Glassfish server, applet does not run.
My applet takes 43 seconds to do processing and get displayed, I think this may be the problem.
When I run the same JSP with the same applet but with slight modification, applet runs correctly with JSP. Modification is that I comment out a function call (called from init()
method) which is responsible for large execution time. The long running method reads three files and generates the output in the choice buttons, i.e. generates the choices.
But I need that function in my applet, that is very important function.
Every catch statement has a printstacktrace()
method call in it.
public void start(){
initialise_maps();
}
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable()
{
public void run() {
initComponents();
}
});
} catch (Exception ex)
{
ex.printStackTrace();
}
// initialise_maps();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来有必要将该方法调用重构为
start()
方法,或者在单独的Thread
中执行此操作(例如使用SwingWorker
)。在
init()
方法中添加选择框,但在start()
方法中填充它们(如果尚未完成 - 每次浏览器从最小化状态恢复时都会调用 start 方法,以及直接在init()
之后调用)。It seems it will be necessary to refactor that method call to the
start()
method, or do it in a separateThread
(e.g. using aSwingWorker
).Add the choice boxes in the
init()
method, but populate them in thestart()
method (if not already done - the start method is called every time the browser is restored from minimized, as well as directly afterinit()
).