Solved

logic problems

Posted on 2006-10-26
10
177 Views
Last Modified: 2010-04-01
i know its kind of sound crazy to post a logic isses under here.

But i do hope you guys can give me a hand

i have this data structure


masterlicenseid     renewid          dateofdownload        dateofrenewal        
7                              2                    18/6/2006                 4/7/2006
7                              3                    18/6/2006                 5/7/2006
100                          12                   23/8/2006                30/8/2006
143                          16                   18/9/2006                1/9/2006
143                           17                  18/9/2006                2/9/2006
143                           18                  18/9/2006                2/9/2006


i wish to diplat the above information like this in the web page

--------------------------------------------------------------------------------------
masterlicenseid       renewid          dateofdownload            dateofrenewal
---------------------------------------------------------------------------------------
7                           2                        18/6/2006                  4/7/2006
                             3                                                         5/7/2006
--------------------------------------------------------------------------------------
100                       12                      23/8/2006                   30/8/2006
-------------------------------------------------------------------------------------
143                      16                       18/9/2006                 1/9/2006
                            17                                                       2/9/2006
                           18                                                        3/9/2066


************

I am totally know how to perform a resultset caputre from the query to db. But i am not sure how can i make it separate basing on the masterlicenseid.

I am manage to group by using the masterlicenseid, but how can i pass the object back to JSP to display? a the renewedid is dynamic.

How would you tackle this? Please share with me.
0
Comment
Question by:chainreaction
10 Comments
 

Author Comment

by:chainreaction
ID: 17810197
this is my program

businessLogic.java

..
..
            stmt = dbConnect();
                  String query = "select * from renewedclientlicenses ";
                  rs = stmt.executeQuery(query);
                  while(rs.next()){
                        ob = new object();
                        ob.setDateOfDownload(rs.getString("dateofdownload"));
                        ob.setDateOfRenewal(rs.getString("dateofrenewal"));
                        ob.setMasterlicenseid(rs.getString("masterlicenseid"));
                        ob.setMobileNumber(rs.getString("mobileNumber"));
                        ob.setRenewedlicenseid(rs.getString("renewlicenseid"));
                        ob.setMonth(df.format(rs.getDate("dateofrenewal")));
                        result_list.add(ob);
                  }
..
..

jsp page
..
..
<%
dbConnection db = new dbConnection();
List data_list = db.getData();
object ob = null;
for (int i=0; i<data_list.size(); i++) {
ob = (object)data_list.get(i);
%>
<tr>
      <td><%= ob.getMasterlicenseid() %></td>
      <td><%= ob.getRenewedlicenseid() %></td>
      <td><%= ob.getMobileNumber() %></td>
      
      <td>
            <% if (ob.getMonth().equals("07")) { %>
                  <b>
                  <%= ob.getDateOfRenewal() %>
            </b>
            <% }  else { %>
                        <%= ob.getDateOfRenewal() %>
      <% } %>

..
..

the output is :

masterlicenId renewlicenseid      dateofrenewal            dateof download
7            31            2006-07-04 20:51:28.0      2006-06-18 20:51:42.0
7            32            2006-07-04 20:53:25.0      2006-06-18 20:51:42.0
64            303            2006-08-04 16:19:48.0      2006-06-21 15:25:14.0
64            25            2006-06-29 21:26:10.0      2006-06-21 15:25:14.0
95            215            2006-07-28 09:48:44.0      2006-06-22 09:19:50.0
95            38            2006-07-05 22:51:39.0      2006-06-22 09:19:50.0
143            1            2006-06-23 11:48:37.0      2006-06-22 11:44:15.0
152            152            2006-07-23 11:37:46.0      2006-06-22 12:06:43.0
152            153            2006-07-23 11:40:31.0      2006-06-22 12:06:43.0
      
0
 

Author Comment

by:chainreaction
ID: 17810200
but then i am expecting the output like this...

masterlicenId renewlicenseid      dateofrenewal            dateof download
7            31            2006-07-04 20:51:28.0      2006-06-18 20:51:42.0
            32            2006-07-04 20:53:25.0      2006-06-18 20:51:42.0
64            303            2006-08-04 16:19:48.0      2006-06-21 15:25:14.0
            25            2006-06-29 21:26:10.0      2006-06-21 15:25:14.0
95            215            2006-07-28 09:48:44.0      2006-06-22 09:19:50.0
            38            2006-07-05 22:51:39.0      2006-06-22 09:19:50.0
143            1            2006-06-23 11:48:37.0      2006-06-22 11:44:15.0
152            152            2006-07-23 11:37:46.0      2006-06-22 12:06:43.0
             153            2006-07-23 11:40:31.0      2006-06-22 12:06:43.0
0
 

Author Comment

by:chainreaction
ID: 17810204
can you share your ideas?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 16

Accepted Solution

by:
suprapto45 earned 360 total points
ID: 17810208
The simple logic would be like

Return query to JSP. The query must be order by masterlicenseid, renewid asc
1. set one temp variable to contain the value of masterlicenseid
1. Loop the result set
    2. if (QUERY(masterlicenseid) == temp)
        3. Do not print masterlicenseid and do not print date of download
    4. else
        5. Print everything
    6. Set the temp to the QUERY(masterlicenseid)
7. End loop

Try to post your current codes and we can have a look
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810215
Okay,

I saw your codes. Please try my logic and let me know if it does not work
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810252
Oppp...typo.

>>"set one temp variable to contain the value of masterlicenseid"
You can just set it as an empty String or 0 if it is int
0
 

Author Comment

by:chainreaction
ID: 17810357
supraptor45, i thought the above problem can be easily sovle by HTML Table code?
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 17810466
>>"can be easily sovle by HTML Table code"
What do you mean?

I do not really get you on this.
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17822908
use Display Tag  
see this for Display Tag
http://displaytag.sourceforge.net/11/

Display tag is very good tag library to display data in tables in your jsps'
0
 
LVL 8

Expert Comment

by:reach2piyush
ID: 17879827
String query = "select * from renewedclientlicenses order by masterlicenseid";

jsp page
..
..
<%
......
String lastRecord = "";
%>
<tr>
     <% if (lastRecord.equals(ob.getMasterlicenseid())) {%>
     <td><%= ob.getMasterlicenseid() %></td>
      <%
         }
         lastRecord = ob.getMasterlicenseid();
       %>
     .......
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AlarmClock Challenge 35 150
mask rule in struts validation.xml 5 87
struts hibernate integration example 28 132
jdbc error in jsp application 20 44
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

786 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