Link to home
Start Free TrialLog in
Avatar of KirtipurItagol
KirtipurItagol

asked on

Search Code + Java+JSP

Hi bloodredsun, I am working on my search screen right now. And I am in very initial phase. I would be very greatful if somebody could show me a way to show the result in a table after clicking the search button.
My problems are how to start coding in my SearchAction.java (connecting to the Oracle 9i, fetching data, and populating in the table).
Here's my html page:

<HTML>
<HEAD>

<TITLE>Identity Management</TITLE>

<link rel="stylesheet" type="text/css" href="includes/flexnav.css">
<script type="text/javascript" src="includes/navigation.js"></script>

</HEAD>

<BODY bgColor=white>

<form action="#" method="post">

<br>

<p class="details">Please search for a legal entity.</p>
<div id="sectionHeader">
<TABLE height="20" cellSpacing=0 cellPadding=0 width="100%" align="center" border="0">
<tr><td id="sectionHeaderLeft">&nbsp;&nbsp;Search Legal Entities:</td>
<td id="sectionHeaderRight">Mandatory fields (*)&nbsp;&nbsp;</td>
</tr>
</TABLE>

</div>
<TABLE cellSpacing=3 cellPadding=0 width="95%" align="center" border="0">
<tr>
<td class="detailbold">Legal Entity Name *</td>
<td align="left"><input type="text" size="35"</td>
<td rowspan="2" background="images/Line_Vertical_dotted.gif" width="1"></td>
<td class="details"></td>
<td width="10%" class="details">Organization Type</td>
<td align="left">
  <select style="width:245" name="orgtype">
  <option value="Corporate">Select</option>
  <option value="Corporate">Corporate</option>
  <option value="Private">Private</option>
  <option value="Public">Public</option>
  </select>
</td>
</tr>

<tr width="50%">
<td class="details">Account number</td>
<td align="left"><input type="text" size="35"</td>
<td class="details"></td>
<td >Branch</td>
<td align="left"><input type="text" size="35"</td>
</tr>
</TABLE>

<br>

<hr align='left' size='1' width='100%' color='navy' noshade>

<br>

<TABLE cellSpacing=0 cellPadding=0 width="100%" align="center" border="0">
<tr>
<td align="right"><a href="#">Search</a></td>
<td align="left"><IMG height=4 src="images\spacer.gif" width=1 border=0></td>
<td background="images/Line_Vertical_dotted.gif" width="1"></td>
<td align="left"><IMG height=4 src="images\spacer.gif" width=1 border=0></td>
<td align="left" ><a href="#">Cancel</a></td>
</tr>
</table>
<hr align='left' size='1' width='100%' color='navy' noshade>
<div id="sectionHeader">
<TABLE height="20" cellSpacing=1 cellPadding=0 width="100%" border=0>
<tr><td id="sectionHeaderLeft">&nbsp;&nbsp;Search Results:</td></tr>
</TABLE>
</div>

<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>

<tr class="tableHeader">
 <td height="20" class="tableHeader"></td>
 <td>Legal Entity Name</td>
 <td >Account Number</td>
 <td >Country</td>
 <td >Currency</td>
 <td >Organization Type</td>
<td >Branch</td>
</tr>

<tr bgcolor="white">
 <td class="detailsCenter" align="center"><input type="radio" name="account"></td>
 <td class="details">Subsidary 1</td>
 <td class="details"><a href="#">54215487</a></td>
 <td class="details">England</td>
 <td class="details">UK Pound</td>
 <td class="details">Corporate</td>
 <td class="details">London</font></td>
</tr>
</TABLE>

<br>

<div style="position: relative; left:31%">
<table  border="0" cellspacing="0" cellpadding="4" bgcolor="white">
<tr>

</tr>
</table>
</div>
</form>
</BODY>
</HTML>
SOLUTION
Avatar of fargo
fargo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KirtipurItagol
KirtipurItagol

ASKER

Ok I'll have this:
AccountMgmt db= new AccountMgmt ();
db.makeConnection();
Connection con = db.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("i DON'T KNOW THIS SELECT QUERY"); // each search fields are in a separate table
Legal entity name is in Legal Entity table under CUSTOMER_NAME
Account number is in  Accoutn Number table under CUSTOMER_ACCT
Organization Type is in Legal Entity table under ORGANIZATION
Branch is in Base Number table under BRANCH_CODE

For the htmls:
<html:text property="legalEntityName" value="" size="35" required="true"/>
<html:text property="existingAccountNumber" value="" size="35"/>
<html:select property="OrgTypeCd" value="" >
      <html:options property="" value="" size="" />
</html:select>
<html:text property="branch" value="" size="35"/>

In the search result table, I need to do something like:
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>

<tr class="tableHeader">
 <td height="20" class="tableHeader"></td>
 <td>Legal Entity Name</td>
 <td >Account Number</td>
 <td >Country</td>
 <td >Currency</td>
 <td >Organization Type</td>
<td >Branch</td>
</tr>

<tr bgcolor="white">
 <td class="detailsCenter" align="center">
<% while(rs.next()) { %>
<input type="radio" name="account"></td>
 <td class="details"><%=rs.getString("legalEntityName") %></td>
 <td class="details"><a href="#"><%=rs.getString("existingAccountNumber") %></a></td>
 <td class="details"><%=rs.getString("country") %></td>
 <td class="details"><%=rs.getString("currency") %></td>
 <td class="details"><%=rs.getString("OrgTypeCd") %></td>
 <td class="details"><%=rs.getString("branch") %></font></td>
</tr>
</TABLE>

<br>

More advises..


Experts, please help me on this. I'm not sure if I am doing it correctly....
What are the connections between the mentioned tables in terms of columns. Logically if you are displaying the result in the report, the report must be having the key columns. and how they are connecting to each other (db foreign key).
hi fargo, i have a query now which works exactly as expected when i ran in toad. it is displaying values in all the columns as expected in the database.
Here's the query:
 SELECT LE.CUSTOMER_NAME LEGAL_ENTITY, LE.LEGAL_ENTITY_ID ACCOUNT_NUM, COUN.COUNTRY_DESCRIPTION COUN_NAME, CURR.CURRENCY_NAME CURR_NAME, LE.GFCID_TYPE ORG_TYPE, BRAN.BRANCH_NAME

 FROM CIF_PROD_OWNER.ECIF_DAM_LEGAL_ENTITY LE, CIF_PROD_OWNER.ECIF_DAM_CUSTOMER CUST, ECIF_BANK_BRANCH BRAN, ECIF_COUNTRY COUN, ECIF_CURRENCY CURR


 WHERE LE.LEGAL_ENTITY_ID = CUST.LEGAL_ENTITY_ID AND LE.COUNTRY = COUN.COUNTRY_CODE AND COUN.CCY_CODE = CURR.CCY_CODE AND CUST.BRANCH_ID = BRAN.BRANCH_ID

 AND LE.CUSTOMER_NAME LIKE '%';

So i don't know how to connect to the database and show the results in the table in my jsp after hitting the submit button.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ur post is quite confusing..at the start u asked about how to make filters over the query using the request params. Then in the next post u ask about SELECT query...then in the very next post u ask about how to make connection to the oracle...

i can see u r using struts. sorry for my last q.

What exactly do u want? could u please clarify?

since the select query is working in TOAD i'm very excited and the question is bit changed. Sorry about that Fargo.
Here is what I'm trying to do. In the searchform I 've four criteria with three text fields and a drop down list to search records from the oracle database on clicking submit button.
The results should be displayed on the same page with two extra columns, that means it will display 6 columns with 4 search criteria.
I created SearchForm.java with four input getters and setters, SearchAction.java, SearchDTO.java with 6 displayed columns getters and setters.
I want to have a SearchDAO.java.
Now I don't know how to make a database connection and where to code these database connection codes.
I don't know how to display the retrieved data from database to my jsp.
And I also don't know where to put my workiing sql query.
I will want to use a hashmap something like :
HashMap hmSearchDet = new HashMap()
hmSearchDet.put("KeyValue",actual Obj);
hmSearchDet.get("KeyValue");

Dear Fargo, please ask me if i'm confusing you. It's due as soon as possible and I'm totally new to this programming environment and I want to live in this field.
Bhaskar
ok. The last link i gave u can help u in getting the connection to the db.
what is SearchDTO.java ?? Are u sure u wish to go with DAO concepts and all.. we can make it more simpler as u are a starter..
yeah i will go with DAO and DTO. where should i put that connection code. Should it be in DAO class or DTO?
But Fargo, if I'm using rational app developer with embedded websphere app server, can't i configure all of those connections in the websphere itself??
SearchDTO is a data ransfer object class. I'm creating it because I have four search criteria and have to display 6 columns from the database. Here i'll be declaring getters and setters for the six columns. And I'll be declaring getters and setters for the four search fields in the regular searchForm.java