Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Search Code + Java+JSP

Posted on 2006-04-06
12
Medium Priority
?
261 Views
Last Modified: 2010-04-01
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>
0
Comment
Question by:KirtipurItagol
  • 7
  • 5
12 Comments
 
LVL 11

Assisted Solution

by:fargo
fargo earned 1500 total points
ID: 16395394
prepare the database sql query and have the page parameters as filters in the WHERE clause of the query.
0
 

Author Comment

by:KirtipurItagol
ID: 16395957
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
 

Author Comment

by:KirtipurItagol
ID: 16396492
Experts, please help me on this. I'm not sure if I am doing it correctly....
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:fargo
ID: 16399053
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
 

Author Comment

by:KirtipurItagol
ID: 16429435
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
 
LVL 11

Accepted Solution

by:
fargo earned 1500 total points
ID: 16430201
the following link will help u how to connect to oracle
http://javaalmanac.com/egs/java.sql/ConnectOracle.html

r u using struts?
0
 
LVL 11

Expert Comment

by:fargo
ID: 16430230
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
 

Author Comment

by:KirtipurItagol
ID: 16430318
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
 
LVL 11

Expert Comment

by:fargo
ID: 16430368
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
 

Author Comment

by:KirtipurItagol
ID: 16430394
yeah i will go with DAO and DTO. where should i put that connection code. Should it be in DAO class or DTO?
0
 

Author Comment

by:KirtipurItagol
ID: 16430408
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
 

Author Comment

by:KirtipurItagol
ID: 16430618
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Conducting a customer service survey used to be as straightforward as sending a template email out using checkboxes and numerical rating systems to measure satisfaction.
Often, the users face difficulty in accessing Outlook 2016 PST files on Windows 10 computer. One of the reasons behind it is the improper functioning of MS Outlook when the user tries to open it. MS Outlook suddenly stops working, or it will not op…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question