I'm trying to get a web based Java Applet to open a user's excel file from their local computer for reading only. It work's of course when I run it as an application from my local computer, but the second I try to run it from a web page it show's the dialog but won't open the file.
I figure it has to do with security and all of that, but I'm not sure. Here is my code, any thought's on how I can get this thing fixed? Everything else work's just great, it's the opening the file I'm missing and I can't find anything on this searching for the past 20 min. on Google.
Code:
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
File file = chooseExcelFile();
// do nothing if open dialog was cancelled
if (file == null) {
return;
}
// loading long excel tables may be time consuming, so use wait cursor
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Sheet sheet = readExcelSheet(file);
if (sheet != null) {
displaySheet(sheet, jTable1);
}
setCursor(Cursor.getDefaultCursor());
stat.setText("Importing data...");
stat.setVisible(true);
value = 100 / Double.parseDouble(Integer.toString(jTable1.getRowCount()));
//System.out.println(value);
//System.out.println(jTable1.getRowCount());
int confirm = JOptionPane.showConfirmDialog(null, "Are you sure you wish to import this file into your store?");
if (confirm == JOptionPane.YES_OPTION) {
new Thread () {
public void run () {
startImp();
}
}.start();
}
}
private File chooseExcelFile () {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new XLSFilter());
int returnVal = chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
return chooser.getSelectedFile();
}
// cancel was clicked
return null;
}
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
Attached is an SS of what my signing screen look's like, I'm using Netbeans by the way.
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
Warning:
This jar contains entries whose signer certificate will expire within six months.
Re-run with the -verbose and -certs options for more details.
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
589 Wed Jun 06 15:26:54 CST 2012 META-INF/MANIFEST.MF
615 Wed Jun 06 15:26:54 CST 2012 META-INF/NB-JWS.SF
786 Wed Jun 06 15:26:54 CST 2012 META-INF/NB-JWS.DSA
0 Wed Jun 06 15:26:56 CST 2012 META-INF/
sm 2354 Wed Jun 06 15:26:54 CST 2012 META-INF/INDEX.LIST
sm 525 Wed Jun 06 15:26:54 CST 2012 impExcel$1.class
sm 670 Wed Jun 06 15:26:54 CST 2012 impExcel$2.class
sm 652 Wed Jun 06 15:26:54 CST 2012 impExcel$3.class
sm 903 Wed Jun 06 15:26:54 CST 2012 impExcel$XLSFilter.class
sm 24363 Wed Jun 06 15:26:54 CST 2012 impExcel.class
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
Looks good to me.
Lets go back to the original problem. What happens when you open the chooser? Can you navigate the file system and actually select a file to use?
Also, when you load the applet it does ask for security confirmation and you accepted correct?
Hmm. I open the browser, load the HTML file (which loads JNLP just so you know), it asks for security confirmation and I accept. Then I click my button to pull up the select dialog, I can navigate and everything just fine, no problem's at all. I then select the file and click ok, just like I do when running as a regular app intead of applet. When running as an app it starts the process. When running as an applet nothing happen's, it just closes the dialog and that's it.
I should mention, I am using Ubuntu to do this on, Chrome testing. But I also tested on FF, but that shouldn't matter since it's not so much the browser but the JRE. I do have IcedTea installed rather than JDK since Ubu's new repo's don't have JDK by default, but IcedTea. Don't know if that would cause problem's.
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
I hate debugging applets when only they are the problem :/
Lets see what happens with this:
PHP Code:
JOptionPane.showMessageDialog(null, "Execute file chooser"); File file = chooseExcelFile(); // do nothing if open dialog was cancelled if (file == null) { JOptionPane.showMessageDialog(null, "File resulted in null."); return; } JOptionPane.showMessageDialog(null, "File looks good to this point");
I tell ya, more times than not I wanna do that ha ha. I had my keybinding for this project for clean and build set to only build and it wasn't replacing the old JAR with my new one, so my browser was running off of my older JAR that had NO action to the button at all!!!
I tell ya sometimes ha ha ha. So I re-did my keybinding to a clean and build and now it's working just fine
Thank's fou, sorry for the brain fart ha ha
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
Quick question, I'm having a heck of a time with my JDBC connect. When I do it with localhost it works fine, but when I use the domain name it doesn't work and the app breaks and no longer does anything at all when I click the button.
But, when I use localhost as my jdbc connection string, even when it's uploaded to my site, it connect's to my local PC's DB, not the server's. I expect this since Java runs the app on client side. So how do I fix this conundrum :S
I know the domain allow's MySQL external access, I have enabled it and checked it from mysql from my local machine, so no problem there.
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
Write a server side handler and use RMI, SOAP or another type of communication to pass requests and responses between them to handle all the dbms actions. You can just rewrite the connection to point to that of the dbms, but I don't like that since the applet codebase can be retrieved by the client in its entirety, and picked enough through you can probably retrieve the username and password.
Hmm, don't like that idea, as you said it kind of leaves things out there
Now I have the old problem again, nothing has changed but the connection string's. Plus I took it back to use localhost instead just to make sure, no go.
Now it just doesn't bring up the choose dialog again. I am PMing you the link so I don't have to paste it publicly here. I don't know what I did :S ha ha
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming
I just added an optionpane for the SQL exception error, so you might have to refresh it to get that, it's throwing it seem's a timeout error :|
__________________
"FORTRAN is not a language. It's a way of turning a multi-million dollar mainframe, into a $50 programmable scientific calculator."
█ █ http://www.microfastcat.com -- FastCat Software, the fastest software on the NET!
█ █ http://www.microthosting.com -- Free reseller web hosting, Hosting, VPS, FREE SMALL HOSTING!!!
█ █ http://www.microtronix-tech.com -- Web design and programming