Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

How to make a scrollable table using Jsp?

Thread view: 
eureka - 27 Jan 2007 16:48 GMT
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!
Lew - 27 Jan 2007 16:58 GMT
> <%
> 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
Andrew Thompson - 27 Jan 2007 17:57 GMT
..
> 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.
>
[quoted text clipped - 3 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.