Logical Display Error

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

princehyderabadAsked:
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.

objectsCommented:
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

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
princehyderabadAuthor Commented:
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
objectsCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

princehyderabadAuthor Commented:
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
KuldeepchaturvediCommented:
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
objectsCommented:
> 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
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.