JavaScript + JSP + MySql
I am working on a project, for which I am using JSP & MySql.
I Have a page index.jsp, which contain a table which displays the content of the database( Using J connector) . There is also a button which when clicked will fold/unfold the table ( meaning.. hide / make it visible ). What I intend to do is that moment the user clicks the button , somehow the table should be updated and be displayed without refreshing the entire page.
Eg:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/test_xp.jsp" %>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_test_xp_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_test_xp_STRING,MM_test_xp_USERNAME,MM_test_xp_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM mysql.sample_xp");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<%
int Repeat1__numRows = -1;
int Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
This is the First Part of my index.jsp
What I am trying to do is something like this ( I know it doesnot work ;) )
<%!
public static void update_table()
{
out.println("<tr>");
out.println("<td width=\"20%\"> </td>");
out.println("<td>Name</td>");
out.println("<td>Group</td>");
out.println("<td>Search_String</td>");
out.println("<td>Date_Of_Access</td>");
out.println("</tr>");
while ((Recordset1_hasData)&&(Repeat1__numRows-- != 0)) {
Object url = Recordset1.getObject("URL") ;
out.println("<tr>");
out.println("<td width=\"20%\"> </td>");
out.println("</tr>");
Repeat1__index++;
Recordset1_hasData = Recordset1.next();
}
out.println("</table>");
}
%>
This is followed by <head>
…….
And in the body part
<button idbut1" class="button-small" onclick="update_table()" style="width:121; height: 33"> <font size="2"> Show Table </font> </button>
Is is possible to achieve what I wanted ?

