my bean/class page
package db;
import java.sql.*;
public class Topic
{
public String topic;
public String topicdis;
public Topic()
{
topic="";
topicdis="";
}
public void setTopic(String val)
{
topic=val;
}
public void setTopicdis(Str ing val)
{
topicdis=val;
}
public String getTopic()
{
return topic;
}
public String getTopicdis()
{
return topicdis;
}
public void CreateTopic()
{
try
{
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
Connection connect = DriverManager.g etConnection("j dbc:odbc:UserMa ster");
PreparedStateme nt prst = connect.prepare Statement("inse rt into Topics(Tname,Td is) values(?,?)");
prst.setString( 1,topic);
prst.setString( 2,topicdis);
prst.execute();
connect.close() ;
}
catch(Exception e)
{
System.out.prin tln(e);
}
}
}
my jsp page
<%@page contentType="te xt/html" pageEncoding="U TF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="ob" class="db.Topic " />
<%
ob.setTopic(req uest.getParamet er("topic"));
ob.setTopicdis( request.getPara meter("topicdis "));
ob.CreateTopic( );
%>
</body>
</html>
jsp page/html page on wich data suld be displayed
<html>
<head>
<body style="backgrou nd-color:lemonchif fon">
<title>topics </title>
<table align="right" border = 5 cellspacing = 5 cellpadding = 10 height=20 width="100%">
<tr>
<th><h1><b>well come to discussion board</b></h1></th>
<th><a href="Createuse r.jsp">Create New User</a></th>
<th><a href="Newtopic. jsp">New Topic</a></th>
<th><a href="Removeuse r.jsp">Delete User</a></th>
<th><a href="loginpage .html">Help</a></th>
<th><a href="Userlogin .jsp">Login</a></th>
<th><a href="Start.jsp ">Logout</a></th>
</tr>
</table>
<table border = 1 cellspacing = 0 cellpadding = 1 width="100%" height="40%">
<br><br><br>
<caption><h1>TO PICS:-</h1></caption>
<tr>
<th>No.</th>
<th>Topic Name</th>
<th>Threads</th>
<th>Posts</th>
<th>Date</th>
<th>Time</th>
</tr>
<tr>
<td>1</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
package db;
import java.sql.*;
public class Topic
{
public String topic;
public String topicdis;
public Topic()
{
topic="";
topicdis="";
}
public void setTopic(String val)
{
topic=val;
}
public void setTopicdis(Str ing val)
{
topicdis=val;
}
public String getTopic()
{
return topic;
}
public String getTopicdis()
{
return topicdis;
}
public void CreateTopic()
{
try
{
Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
Connection connect = DriverManager.g etConnection("j dbc:odbc:UserMa ster");
PreparedStateme nt prst = connect.prepare Statement("inse rt into Topics(Tname,Td is) values(?,?)");
prst.setString( 1,topic);
prst.setString( 2,topicdis);
prst.execute();
connect.close() ;
}
catch(Exception e)
{
System.out.prin tln(e);
}
}
}
my jsp page
<%@page contentType="te xt/html" pageEncoding="U TF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="ob" class="db.Topic " />
<%
ob.setTopic(req uest.getParamet er("topic"));
ob.setTopicdis( request.getPara meter("topicdis "));
ob.CreateTopic( );
%>
</body>
</html>
jsp page/html page on wich data suld be displayed
<html>
<head>
<body style="backgrou nd-color:lemonchif fon">
<title>topics </title>
<table align="right" border = 5 cellspacing = 5 cellpadding = 10 height=20 width="100%">
<tr>
<th><h1><b>well come to discussion board</b></h1></th>
<th><a href="Createuse r.jsp">Create New User</a></th>
<th><a href="Newtopic. jsp">New Topic</a></th>
<th><a href="Removeuse r.jsp">Delete User</a></th>
<th><a href="loginpage .html">Help</a></th>
<th><a href="Userlogin .jsp">Login</a></th>
<th><a href="Start.jsp ">Logout</a></th>
</tr>
</table>
<table border = 1 cellspacing = 0 cellpadding = 1 width="100%" height="40%">
<br><br><br>
<caption><h1>TO PICS:-</h1></caption>
<tr>
<th>No.</th>
<th>Topic Name</th>
<th>Threads</th>
<th>Posts</th>
<th>Date</th>
<th>Time</th>
</tr>
<tr>
<td>1</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>2</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>