File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP to Access 2000 database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP to Access 2000 database" Watch "JSP to Access 2000 database" New topic

JSP to Access 2000 database

Joe Lee

Joined: Aug 01, 2002
Posts: 7
Hi All,
I'm new to JSP's. I have a Access 2000 db called Info, containing one table called Names.
How can I access it using a JSP.
Mat Robinson

Joined: Aug 02, 2002
Posts: 20
If you are new to JSP, you should start by looking at the three-tier architecture and MVC. The JSP does not directly access the database, but through a middle-tier.
The three tiers are roughly,
Presentation: JSP et al. for displaying.
Business: The business logic.
Integration: This is where the database code sits.
I recommend looking at the frameworks available on the Jakarta website. Especially Struts, which should help you start off.
Good luck,
Joe Lee

Joined: Aug 01, 2002
Posts: 7
Hi Matt,
I have a small amount of knowledge about JSP.
The problem is that I'm not sure how to set the
following up to point to the db.
Class.forName("driver stuff");
conn =
("jdbc stuff", "username", "password");
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You can search this forum and also look at the JDBC tutorial at
What matt is saying is that you are better having the JSp deal with the presentation of the page only, and have a bean or even a controller servlet that will do the DB connection and return the results to the presentation tier (Your JSP). Search google or the forum for MVC or Model 2 architecture.

So much trouble in the world -- Bob Marley
Steven Kors
Ranch Hand

Joined: Jan 30, 2002
Posts: 33
Lets see if i can help a little. First i will point you to the resources that you will need to accomplish your endeavor.
MVC == the following;
M = model or the business logic (database access, typically Servlet)
V = view represents what the client sees (JSP)
C = Controller is a servlet that forwards requests to the View and models respectively.
If your application is a simple one you should still try to maintain the MVC (or model 2)structure as much as possible. Consider this good habit forming. You can find information on the MVC or Model 2 design patters here;
Here is SUN's representation of the MVC architecture:
Here is another good description of the MVC architecture:
Once you have mastered the MVC (model 2) architecture, try your hand at the STRUTS design pattern. I wouldnt try struts until you are firm in your knowledge of MVC.
STRUTS located here;
OK so now that you know more about MVC, lets try and understand JSP a little better. In order to understand JSP you really should understand Servlets as JSP pages are compiled into servlets by the container that you are using. Here are some links to JSP and servlet tutorials;
Here is lthe link that will take you to the Tutorial pages.
Here is a tutorial on Servlets (Because its important to know what servelts are and what they do).

Here is the tutorial on the JSP pages. This should really put things together for you after going through the servlet tutorial
Please pay special attention to how beans are used between servlets and JSP pages. Java Beans help pass information and also help in reducing code duplication and also help in reducing code duplication and also help in reducing code duplication and also help in reducing code duplication and also help in reducing code duplication and also help in reducing code duplication and also help in reducing code duplication .. annoying wasn’t that? If that was annoying then I am sure you would find rewriting code over and over again just as annoying hehe
Now one last refresher on JDBC ...
All the tutorials that i have listed can be found, on the tutorial link i listed above.
I would highly recommend the books by Marty Hall (core servlets and java server pages and More servlets and java server pages) they are great starter books for people trying to get a handle on servlets and JSP.
Ok, i think we are ready to tackle your problem now. : )
When a request comes into your controller servlet, the servlet will determine what view page (JSP) that will handle the request. When it forwards the request to the JSP page, this page will call the business logic it needs to create the page (typically servlets BUT if could be other JSPs as well).
Since you went through the MVC information I will not get into the specifics with respect to how the Controller forwards to the VIEW. The view will call a servlet(model) that connects to your database and gets the data to display for your user (whether its selected data or preformed data). You can either call the servlet directly using JSP script or create a tag library (a whole new can of worms … if you get the Core and More servlets and JSP books, Tag libraries are covered) . Lets use the following to call the model servlet;
<jsp:include page="servlet/GetTheRequestedData" flush="true" />
When you use this call you must make sure that you return HTML, otherwise it will not function correctly.
Since you are going to run out and buy the “Core servlets and java server pages” book(get the book so I don’t feel guilty on posting the links to the books web site ), in the 18th chapter you will find a section of DB access and connection pooling. I HIGHLY recommend that you implement some type of connection pooling scheme other wise you will run into a whole new mess of problems.
Go to this web page select chapter 18 and build the DBResults class and all the classes for the connection pooling example (get the book if you want to understand how it works … ok did I plug the book enough sheesh) This DBResults class takes a query and stores the data into a vector. It also includes a method to convert this Vector data (the data you called from the database ) into an HTML table if that is what you need. Really you can put the data into whatever format you wish but when I was beginning JSP and Servlet development this class really helped me understand what I needed to do to enable my web applications to have a lot more versatility. Once your servlet has the data and has formatted the data to your liking, this data will be returned to the jsp page using the PrintWriter.
You should now have all the information you need to solve your problem. The short courses are the best way to quickly educate yourself and bring your self up to a coding level where you will not have much down time in the future. Spend the time now and you will save time later.
I hope I have helped you even just a little
[ August 08, 2002: Message edited by: Steven Kors ]
[ August 08, 2002: Message edited by: Steven Kors ]

Tao Lee

Joined: Aug 08, 2002
Posts: 1
The following could solve your problem:
conn = DriverManager.getConnection
("jdbc odbc DSN", "username", "password");
(Note there should be a : between jdbc and odbc, and odbc and DSN. But if I put : there, appears.)
Here DSN is not your Access file. It is Data Source Name. You need to configure Database to associate your Access file with DSN. You may refer to Appendix C in book "JSP: JavaServer Pages" by Barry Burd on how to configure a database with Access in Windows.
[ August 08, 2002: Message edited by: Tao Lee ]
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Here's a JSP link just to add to Steven's excellent post above...
I agree. Here's the link:
subject: JSP to Access 2000 database