JTwain doesnt work in jsp using servlet

731 views Asked by At

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?

1

There are 1 answers

5
Paŭlo Ebermann On BEST ANSWER

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?