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>
KirtipurItagolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
prepare the database sql query and have the page parameters as filters in the WHERE clause of the query.
0
KirtipurItagolAuthor Commented:
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..


0
KirtipurItagolAuthor Commented:
Experts, please help me on this. I'm not sure if I am doing it correctly....
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

fargoCommented:
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).
0
KirtipurItagolAuthor Commented:
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.
0
fargoCommented:
the following link will help u how to connect to oracle
http://javaalmanac.com/egs/java.sql/ConnectOracle.html

r u using struts?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fargoCommented:
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?

0
KirtipurItagolAuthor Commented:
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
0
fargoCommented:
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..
0
KirtipurItagolAuthor Commented:
yeah i will go with DAO and DTO. where should i put that connection code. Should it be in DAO class or DTO?
0
KirtipurItagolAuthor Commented:
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??
0
KirtipurItagolAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.