?
Solved

Logical Display Error

Posted on 2005-03-09
6
Medium Priority
?
204 Views
Last Modified: 2010-04-01
hi everyone,

Out put  of a Storage Procedures is something like this:
-------------------------------
Name            FileSize
------------------------------
Bat.exe           52344
Read.txt             413
Install.iso         1111
------------------------------

MY JSP CODE: (Correct my code to display how I wanted)
...
 while (rs.next()) {
     out.print("Install ISO:"+ rs.getString(1));
     out.print("<BR>");
     out.print("File Size:"+rs.getString(2));
     out.print("<BR>");
     out.print("Batch File:"+ rs.getString(1));
     out.print("<BR>");
     out.print("File Size:"+rs.getString(2));
     out.print("<BR>");
     out.print("Read Me File:"+ rs.getString(1));
     out.print("<BR>");
     out.print("File Size:"+rs.getString(2));
     out.print("<BR>");
....

the output I'm getting is
==========================
Install ISO:     Bat.exe          
File Size:        52344
Batch File:      Bat.exe
File Size:        52344
Read Me File: Bat.exe
File Size:       52344

Install ISO:     Read.txt          
File Size:        413
Batch File:      Read.txt
File Size:        413
Read Me File:  Read.txt
File Size:       413

Install ISO:     Install.iso          
File Size:         1111
Batch File:      Install.iso
File Size:         1111
Read Me File:  Install.iso
File Size:        1111

==========================
But I want the output in this way:
       
Install ISO:     Install.iso          
File Size:         1111
Batch File:      Bat.exe
File Size:         52344
Read Me File:  Read.txt
File Size:         413

Regards,
Hyd

0
Comment
Question by:princehyderabad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 13502028
try:

if (rs.next())
{
     out.print("Install ISO:"+ rs.getString(1));
     out.print("<BR>");
     out.print("File Size:"+rs.getString(2));
     out.print("<BR>");
     if (rs.next())
     {
        out.print("Batch File:"+ rs.getString(1));
        out.print("<BR>");
        out.print("File Size:"+rs.getString(2));
        out.print("<BR>");
     }
     if (rs.next())
     {
        out.print("Read Me File:"+ rs.getString(1));
        out.print("<BR>");
        out.print("File Size:"+rs.getString(2));
        out.print("<BR>");
     }
   }
}

0
 

Author Comment

by:princehyderabad
ID: 13502076
Half the way ...

DB giving back the result set in this order:
Bat.exe        
Read.txt        
Install.iso      

Using your above code able to display correct, but my problem is I want to arrange the out in this order.
1. Install.iso
2. Bat.exe
3. Read.txt

0
 
LVL 92

Expert Comment

by:objects
ID: 13502327
maybe something like:

Map sizes = new HashMap();
while (rs.next())
{
   sizes.put(rs.getString(1), rs.getString(2));
}
out.print("Install ISO: Install.iso");
out.print("<BR>");
out.print("File Size:"+sizes.get("Install.iso"));
out.print("<BR>");
out.print("Batch File: Bat.exe");
out.print("<BR>");
out.print("File Size:"+sizes.get("Bat.exe"));
out.print("<BR>");
out.print("Read Me File: Read.txt");
out.print("<BR>");
out.print("File Size:"+sizes.get("Read.txt"));
out.print("<BR>");
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:princehyderabad
ID: 13508771
I didnt try your code this morning. but I have a Question, you are saying here:
sizes.get("Install.iso")
sizes.get("Batch.exe")
sizes.get("Read.txt")
But I dont know if DB will have  this names or others, it can be 'Installer.iso1' not necessary 'Install.iso'.

please explain..
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 13509985
you  can add a "order by name" in your stored procedure so it returns the data in your required order and after than object's code can be used to display it.
0
 
LVL 92

Expert Comment

by:objects
ID: 13510578
> But I dont know if DB will have  this names or others, it can be 'Installer.iso1' not necessary 'Install.iso'.

Then how do you know what label to display for each row?
eg. which row is Inall ISO:, which row is Read Me File: etc
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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