aspose file tools*
The moose likes Applets and the fly likes access MS Access database from applet on a jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "access MS Access database from applet on a jsp page" Watch "access MS Access database from applet on a jsp page" New topic
Author

access MS Access database from applet on a jsp page

Olivier Savels
Greenhorn

Joined: Jun 10, 2013
Posts: 4
Hey,

I'm struggling with this for days now.
For a schoolproject I need to build a basketmanager in java. It stores data from players like how many three pointer they have made in this season.
I have a desktopversion wich is working perfectly fine and an applet version wich also works perfectly fine in an applet viewer, but I also have a web project
in wich I call a jsp page from a servlet. On that jsp page the applet is loaded correctly but I can't see any data... And I don't know why or what to do to make it work.

To make matters even worse, my data is stored in a MS Access database. Can somebody please tell me how I can make the applet on the jsp page work just like in the applet viewer.

Here's my jsp code:



thanks for your help, I can't find the solution on my own after hours of googling and trial and error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
For starters, get familiar with the Java Console (which can be started from the Java Control Panel). I am almost positive that it will contain error messages.

Your applet most likely will need to be signed in order to be allowed to access an Access DB. Start reading here about how to make that happen: https://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem


Ping & DNS - my free Android networking tools app
Olivier Savels
Greenhorn

Joined: Jun 10, 2013
Posts: 4
Thanks for the answer, I managed to sign the jar file,

but when I launch it in my web application, the javacontrol panel now tells me that I have an SQL exception and that it can't find the database.

So I still have one question, where should I put the accdb file so the jar can access it?

private static String databank = "./basket.accdb"; this is used to built connection with databank, the code is fine but what's my ./ directory to put basket.accdb in in a web environment.

This is my directory structure where the jar resides:

BasketBall_Coaching_web\Web Pages\

inside the folder Web Pages we have the jar and the accdb database but when I run it, the jar can't find the database.

thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
You need to use absolute paths, not relative paths.
Olivier Savels
Greenhorn

Joined: Jun 10, 2013
Posts: 4
Ulf Dittmer wrote:You need to use absolute paths, not relative paths.


Absolute paths on a webserver, I guess I can understand why, but what if you move the web files from one server to the other... ?
I always thought relative paths where best practices.

What's the startup folder for a webproject? Just Web? I'll give it a shot, this means I'll have te make a new jar file and sign it again.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
There's no concept of a relative path for web apps, so you must use an absolute path. ServletContext.getRealPath(java.lang.String) can help you abstract out the path to the web app root, thus addressing your concern.
Olivier Savels
Greenhorn

Joined: Jun 10, 2013
Posts: 4
Ulf Dittmer wrote:There's no concept of a relative path for web apps, so you must use an absolute path. ServletContext.getRealPath(java.lang.String) can help you abstract out the path to the web app root, thus addressing your concern.


Thank you for the clear answer, I'm glad I finally found a good place for java help and learning. I already learned a lot.
This solved all my problems + signing the jar.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: access MS Access database from applet on a jsp page