Click to See Complete Forum and Search --> : Retrieving data from a database


piertiong
03-26-2003, 06:35 PM
Hi there,

I would like to ask you guys something about JSP here since I can't find any JSP forum here.

My question is, how should I go about retrieving data from a microsoft access database and show it on a form in a .jsp page?

eg, retrieved gender from database. ie male.

How do I make it such that the form shows male as the selected option in the list menu?

piertiong
03-26-2003, 06:49 PM
like this?

<select name="gender">
<option>Please select</option>
<% if(genderQ.equals("male")){ %>
<option value="male" selected>Male</option>
<option value="female">Female</option>
<% } else { %>
<option value="male">Male</option>
<option value="female" selected>Female</option>
<% } %>
</select>

If it's like that, what if I'm doing it for country? I mean, there's so many countries which mean I have to do many if-else loops?

Are there any short cuts?

khalidali63
03-26-2003, 07:32 PM
thats no simple task.

1.First you need to create DSN (Data Source Name) on your system that points to the database.

2.Then you have to have a webserver running like Tomcat or JRun

then you need to write some java code to connect to the db..and list goes on.

your best bet is to go to here

http://forum.java.sun.com/forum.jsp?forum=33

Hope this helps

Cheers

Khalid

piertiong
03-26-2003, 07:36 PM
Originally posted by khalidali63
thats no simple task.

1.First you need to create DSN (Data Source Name) on your system that points to the database.

2.Then you have to have a webserver running like Tomcat or JRun

then you need to write some java code to connect to the db..and list goes on.

your best bet is to go to here

http://forum.java.sun.com/forum.jsp?forum=33

Hope this helps

Cheers

Khalid

hey thanks for the prompt reply, i'll try that website out.