JTwain 无法在使用 servlet 的 jsp 中工作
我已经下载了 JTwain api 并创建/测试了一个 java 类来连接到我的扫描仪,打开扫描仪 UI 并将图像扫描回 java,没有任何问题。
然后,我尝试在 tomcat 中创建一个 JSP,其中表单操作连接到 servlet doPost 方法,然后调用 JTwain 方法。
我遇到的问题是,柯达扫描仪窗口没有要求我按扫描,而是网页冻结了。我放置了一些 system.outs 来检查它冻结的位置,并在 2 处停止,就好像柯达扫描仪对话框正在显示并等待我按下扫描按钮一样。
public static Image initScan(){
try {
Source source = SourceManager.instance().getDefaultSource();
System.out.println(1);
source.open();
System.out.println(2);
Image image = source.acquireImage();
System.out.println(3);
return image;
}catch(Exception e) {
e.printStackTrace();
return null;
}finally{
SourceManager.closeSourceManager();
}
}
我认为它会像任何文件打开对话一样工作,但显然不是,有什么建议吗?
I have downloaded the JTwain api and created/tested a java class to connect to my scanner, open the scanner UI and scan image back into java without any problems.
I then tried to create a JSP in tomcat where form action connects to servlet doPost method, which then calls the JTwain method.
The problem im getting is that instead of getting the kodak scanner window asking me to press scan the webpage just freezes. I put some system.outs to check where it freezes and it stops at 2 as if the kodak scanner dialog is displaying and waiting for me to press the scan button.
public static Image initScan(){
try {
Source source = SourceManager.instance().getDefaultSource();
System.out.println(1);
source.open();
System.out.println(2);
Image image = source.acquireImage();
System.out.println(3);
return image;
}catch(Exception e) {
e.printStackTrace();
return null;
}finally{
SourceManager.closeSourceManager();
}
}
I assumed it would work like any file open dialogue but clearly not, any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对JTwain一无所知,但是JSP是在服务器上执行的,而不是在客户端上执行的。我想您的 Tomcat 无法访问 GUI 界面,这可以解释它无法打开窗口。 (或者它会在服务器上打开您看不到的窗口。)
您在服务器日志文件中看到任何内容吗?
I don't know anything about JTwain, but the JSP is executed on the server, not the client. And I suppose your Tomcat has no access to a GUI interface, which would explain that it can't open a Window. (Or it opens the window on the server, where you can't see it.)
Do you see anything in the server logfile?