473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Retrieve data from database using java beans in jsp

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(String val)
{
topicdis=val;
}
public String getTopic()
{
return topic;
}
public String getTopicdis()
{
return topicdis;
}
public void CreateTopic()
{
try

{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect = DriverManager.getConnection("jdbc:odbc:UserMaster" );
PreparedStatement prst = connect.prepareStatement("insert into Topics(Tname,Tdis) values(?,?)");
prst.setString(1,topic);
prst.setString(2,topicdis);
prst.execute();
connect.close();
}

catch(Exception e)
{
System.out.println(e);
}
}
}



my jsp page

<%@page contentType="text/html" pageEncoding="UTF-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(request.getParameter("topic"));
ob.setTopicdis(request.getParameter("topicdis"));
ob.CreateTopic();
%>
</body>
</html>

jsp page/html page on wich data suld be displayed

<html>
<head>

<body style="background-color:lemonchiffon">
<title>topics</title>


<table align="right" border = 5 cellspacing = 5 cellpadding = 10 height=20 width="100%">

<tr>

<th><h1><b>wellcome to discussion board</b></h1></th>
<th><a href="Createuser.jsp">Create New User</a></th>
<th><a href="Newtopic.jsp">New Topic</a></th>
<th><a href="Removeuser.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>TOPICS:-</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>
Mar 31 '10 #1
0 2771

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Phil Powell | last post by:
Ok, I installed ANT, I have c:\ant in my ANT_HOME environment variable, I have c:\ant\bin in my PATH environmental variable, I installed the JAR files for TCL and for Javascript (Rhino)... to no...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
3
by: Dan | last post by:
Hello, I'm getting started on my first java project. I'm likely going to use jsp/servlets connected to javabeans. The beans will connect to my backend and get/set information for me. When...
0
by: Joyce | last post by:
The XML Schema design problem to solve is as follows: We have 2 combo boxes to populate from schema data, let's say: 1. States 2. Cities (and this one gets populated depending on the choice of...
3
by: Alex | last post by:
Hi all, I'm looking for some advice on how best to implement storage of access logs into a db/2 8.1.4 database running on a RH 7.2 system. I have 5 (squid) web caches running here that...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
4
jeffbroodwar
by: jeffbroodwar | last post by:
Hi Guys, I just want to hear your understanding of Java Beans. I mean it doesn't just expose properties (for parameters) right? Java beans must be able to do what variables can't. i need...
3
by: arasub | last post by:
ep 20, 2007 11:25:57 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
9
by: gavy7210 | last post by:
hello friends i am new to struts. i want to add the user information in the database and then display it back to him. i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.