How to make a scrollable table using Jsp?

E

eureka

Helo Friends,

I am a novice programmer, I'm working with Jsp + Javascript to develop
a web application.

I have a floating table in my webpage which I achieved using JS. I
have written Jsp code to get database records one by one and append it
to this table(i.e basically the table is being created on the fly),
its all good till here but now I need to make this table scrollable
and thats where I'm stuck!

Here is a snapshot of my webpage:- http://www.thescripts.com/forum/
attachment.php?attachmentid=135

The code(Jsp) is as below:-

Code:
<%
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<style type=text/css>table.T1 {overflow: scroll}</style>");
out.write("<layer id = divStayTopLeft>");
out.write("<div align = right>");
out.write("<table class = T1 align = right border = 1 width=450
cellspacing = 0 cellpadding = 0 >");
out.write("<tr><td bgcolor=#FFFFCC><b>Candidate Name</b></td>");
out.write("<td bgcolor=#FFFFCC><b>Batch-ID</b></td>");
out.write("<td bgcolor=#FFFFCC><b>Reg Amt</b></td>");
out.write("<td bgcolor=#FFFFCC><b>Total Fees </b></td>");
out.write("<td bgcolor=#FFFFCC><b>Balance</b></td></tr>");

// Here I have the code for getting the backend-table's record and
appending it to the Html table as a new row.

out.write("</table>");
out.write("</div>");
out.write("</layer>");
out.write("</head>");
out.write("</html>");
%>

The above code is supposed to make my table scrollable, but it doesn't
work, can someone check it for me please and advice me how to go about
it? Or if any other approach of carrying this out ? Please suggest!
 
L

Lew

eureka said:
<%
out.write("<html>\r\n");
out.write("<head>\r\n"); ....
%>

This is not very good JSP style. A JSP exists to obviate the need for
"out.write()", but here you slip into scriptlet mode in order to put those
calls back in.

Better would be:

<html>
<head>
....

Note the utter lack of scriptlet or "out.write()".

Explicit "\r\n" line terminators are another Bad Idea.

- Lew
 
A

Andrew Thompson

I am a novice programmer, I'm working with Jsp ..

i.e. HTML (so far as the user agent sees or cares) -
it is important to remember that.
...+ Javascript to develop a web application.

I have a floating table in my webpage which I achieved using JS. I
have written Jsp code to get database records one by one and append it
to this table(i.e basically the table is being created on the fly),
its all good till here but now I need to make this table scrollable
and thats where I'm stuck!
....
You got stuck when you jumped in at the deep
end, as many Java programmers who code JSP
or servlets do. The 'deep end' is trying to code
HTML and JS via. a third language.
Code:
<%
out.write("<html>\r\n");

Lew mentioned about the line feeds, but I
will point out that this HTML does not claim
to adhere to any W3C recommendation, and
that makes it harder for browsers to parse the
HTML correctly.
out.write("<head>\r\n");
out.write("<style type=text/css>table.T1 {overflow: scroll}</style>");

text/css should be enclosed in quotes or
delimiters 'text/css' or "text/css" it is best
to put styles into external stylesheets, both
to allow caching of styles, as well as to
ensure the styles can be easily validated.
out.write("<layer id = divStayTopLeft>");

Layer was some element invented by netscape,
I do not know if was a valid HTML 3.2 element,
but it sure is not valid in HTML 4.01 (which has
other, valid and reliable ways to replicate the
ability of layers)
out.write("<div align = right>");

Again with the lack of delimiters for attributes,
and inline styles (bad, bad).
out.write("<table class = T1 align = right border = 1 width=450

Putting a size to tables is (usually) a bad move,
they naturally assume as much space as they
need, and if the page becomes too thin, they
can automatically squeeze, to a point.
cellspacing = 0 cellpadding = 0 >");
out.write("<tr><td bgcolor=#FFFFCC><b>Candidate Name</b></td>");

The table cell BG color can be set, once
in the external, cached stylesheet, if you
specify the color as applying to TD elements
that are children of 'T1', you can even have
other normally colored tables on the page.
....
// Here I have the code for getting the backend-table's record and
appending it to the Html table as a new row. ....
The above code is supposed to make my table scrollable, but it doesn't
work, can someone check it for me please and advice me how to go about
it?

Create a static version of this as HTML 4.01,
change the layers for DIV's. externalise the
stylsheets and JS, validate the lot, then take
it to the comp.lang.javascript group and ask
their advice on your DHTML.

Once you have a (D)HTML page with a scrolling
table, that degrades gracefully (a JS term) to
pure HTML, rewrite the details into your JSP,
and Bob's your uncle.

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top