How to query database through button click event from JSP

Hi all,

I can retrieve the values from DB and print them onto a JSP. However, I can't do the reverse process- that's queries DB through a button click event from a JSP. Here is my sample code. I am using struts framework. I tried to execute the code after minimizing errors and all I could get is form bean null exception.

<tr>

<td colspan="2">

<table width="100%" border="0" class="tdbgdark">

<tr>

<td colspan="2">Add Employee</td>

<td colspan="20"> </td>

</tr>

<tr>

<td>Employee Number</td>

<td><label> <input name="employeeNumber" type="text" id="employeeNumber" maxlength="10" /> </label></td>

<td><label>or Employee Name</label></td>

<td colspan="5"><label> <input name="name" type="text" id="name" maxlength="50" /> </label></td>

</tr>

<tr class="tdbgdark">

<html:button property="button" value="Get Employee" />

/* AFTER THE USER CLICKS ON THIS BUTTON- DB NEEDS TO BE QUERIED */

</tr>

<tr>

<td align="center" colspan="4">// HERE RESULTS ARE DISPLAYED</td>

</tr>

<tr class="tdbgdark">

<td colspan="4" align="center">Highlight one employee from the list above</td>

</tr>

Thanks and Regards,

[2008 byte] By [PaviEluri20a] at [2007-11-27 11:49:45]
# 1

Submit the form after you clicked the button,

function submitThis()

{

document.forms[0].submit();

}

<html:button property="button" value="Get Employee" onClick="javascript:submitThis()" />

Whatever the action you have defined in your jsp get triggered.

<html:form action="retrieveAction">

You will define "retrieveAction" action mappings in your struts-config file.

In this action, fetch the data.

skp71a at 2007-7-29 18:27:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Set an action to the button. On click submit the form and hit the database from your action class. Populate your form bean and return the response.

SirG

SirGenerala at 2007-7-29 18:27:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thank you very much. Seems like it is working but I have some problems with form bean. Trying to figure it out. I am now getting parse int error.

PaviEluri20a at 2007-7-29 18:27:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...