princehyderabad
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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>");
Map sizes = new HashMap();
while (rs.next())
{
sizes.put(rs.getString(1),
}
out.print("Install ISO: Install.iso");
out.print("<BR>");
out.print("File Size:"+sizes.get("Install.
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>");
ASKER
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..
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..
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.
> 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
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
ASKER
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