CGI + databases + java

I'am making a programa in Java (applets) Client-Server.
The users access the systems with their browsers.
First they call an HTML initial page then
I have another pages wich have a Menu with options wich access
to the DataBases.
One option in the program is List the elements of a table.
What I want is list the elements of the table and Display them
in a HTML Table,
Somebody told me that this is possible that it is possible to
write server-side java (SERVLETS) or with CGI
JDBC offers possibilities to access databases.
but I really don't know how to do it.
Can Anybody give me THE CODE wich I have to write to do this?

Extra Information:

What I need is that the server send me a HTML page
having a table with the result of the SQL question.
The final objetive of that table is that the user
can send it to the Printer.
 I need to send this result to the
Printer so the easy way for me to do this is that the
server send me the results in a HTML page.
PD: I don´t know nothing of CGI so please be as clear as possible
LVL 1
PampaAsked:
Who is Participating?
 
aioudineConnect With a Mentor Commented:
You may acces database by using two method:

1) Applet on client workstation worked as RMI client
Java apllication (not servlet) worked in as RMI server
Applet send request to RMI server, RMI server access database using JDBC and return
result to RMI applet

see http://javaboutique.internet.com/article_Bi-Directional_RMI.html
for more info about RMI

2) On clent side you use just a <FORM> which send CGI request to server
On server you run SERVLET, which access database using JDBC or thin database driver
result returnes to client as HTML page

IMHO, servlet is better solution, becouse you may access DB from any browser,
without java on client side
--------
How to do this?
First you should learn what is servelet and how they work
read  "Goodbuy CGI, Say Hello to servlet"
thttp://www.webreview.com/97/10/10/feature/
and see links at bootom

Second downoad JSDK (java servlet developers kit)
JSDK available for downloading from http://www.javasoft.com 
(Click on product&API then go to "Servlet developers kit")


Third Install Servlet support for youre web server
many webservers embed support for Servlet (Like Netscape, servers, Tengah Weblogic,
SUN JavaWebserver, O'reilly WebSite Pro, NewAtlanta's ServletExec)
JSDK also included support for IIS and Apache

If youre servler not listed or you wish to use more robust solution
look for JRUN, product available from Live Software at http://www.jrun.com/
(Free lite version available for free)

for testing purpose JSDK also included srun - small program whitch allow to run and test servlet without webserver (Say on Win95 computer)
--------
As far as you are newbie I recommend you download JSDK from sun
install it on Win95 mashine and play with it



Articles "Introduction to Database Programming with Servlets" available from ServletCentral at
http://www.servletcentral.com/1998-10/colton.dchtml
(Source code included)


Additional information:
1) Servlet training availble at http://www.nova-labs.com/
2) Weblogic Tengah (servlet application server with database support):  http://www.weblogic.com
3) Javasoft home: http://www.javasoft.com
4) ServletCentral (Articles, resourses, review etc): http://www.servletcentral.com
5) ServletSource(Tips. tutorials etc): http://www.servletsource.com/
6) Article "Java DataBase Connectivity" with examples :  http://www.berger.com/jdbcpres.html
7) Introduction to JDBC programming at http://www.suite101.com/articles/article.cfm/1956
8) "Java meet CGI"  at http://www.webdeveloper.com/categories/java/java_meets_cgi.html
9)  "Comparison of JDBC and Java to HTML/CGI"
http://www.cariboulake.com/techinfo/java_html.html
10) "Java Apache Project" http://jserv.apache.org/
11) Disccusion transcript from JAvaOne
"Programming the Java Servlet API"
http://sunsite.compapp.dcu.ie/IJUG/javaone/transcripts/program.html






0
All Courses

From novice to tech pro — start learning today.