Displaying Rows


Displaying Rows

View Answers

April 28, 2008 at 6:56 PM

Hi friend,

This is form code,


<title>display data in servlet</title>
<table border="1" width="50%" cellspacing="0" cellpadding="0">

<td width="100%">
<h2 align="center"> Display Data In Servlet</h2>
<form method="GET" action="DisplaydataAction">

<table border="1" width="100%" cellspacing="0" cellpadding="0">
<td width="30%"><b>Name:</b></td>
<td width="70%"><input type="text" name="name" size="20"></td>
<td width="30%"><b>Position :</b></td>
<td width="70%"><input type="text" name="position" size="20"></td>
<td width="30%"><b>Description:</b></td>
<td width="70%"><textarea rows="7" name="description" cols="30"></textarea></td>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="B2"></p>



import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DisplaydataAction extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException{
PrintWriter out = response.getWriter();
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
String driver = "com.mysql.jdbc.Driver";
con = DriverManager.getConnection(url+db,"root","root");
Statement st = con.createStatement();
String firstname=request.getParameter("name");
String address=request.getParameter("position");
String description=request.getParameter("description");
int val = st.executeUpdate("insert dispalyInfo values(id,'"+firstname+"','"+address+"','"+description+"')");
out.println("Successfully insert data in database");
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
catch (Exception e){





read for more information,


April 28, 2008 at 6:59 PM

Display code,

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class RetriveDataAction extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException {
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
Statement stmt = null;
ResultSet rs = null;
PrintWriter out = res.getWriter();
try {
con = DriverManager.getConnection(url+db,"root","root");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT name, position,discription FROM dispalyinfo");
out.println("<html><head><title>Display Data from Database</title></head>");
out.println("<table border=1");
out.println("<html><head><title>" +
"<body bgcolor=\"#FFFFFF\">\n" +
"<table border=1 align=center>\n" +
"<TR bgcolor=\"#8AEAF4\">\n" +
while(rs.next()) {
out.println("<h2>Display Data From Database</h2>");
out.println("<td>" + rs.getString("name"));
out.println("<td>" + rs.getString("position"));
out.println("<td>" + rs.getString("discription"));
catch(ClassNotFoundException e) {
out.println("Couldn't found database driver: " + e.getMessage());
catch(SQLException e){
out.println("SQLException caught: " + e.getMessage());
finally {
try {
if (con != null) con.close();
catch (SQLException sql) {



Related Tutorials/Questions & Answers:
displaying data
displaying data   how to display data from database on jsp using struts2
Image is not displaying
Image is not displaying  Hii i am using spring javamail with html template to send mail,i am facing that image displaying prob when mail have to cm in gmail,in template just i am giving my current location of image which
displaying image
displaying image  how to upload image and retrieve it form database mysql in php?   Here is an example of uploading image using php. 1)form.html: <form method="post" enctype="multipart/form-data" action="upload.php
PHP Displaying URL Content
PHP Displaying URL Content  In my PHP application form, on submitting the form details it always displaying url content. Can anyone tell me what is the reason and how to restrict it from displaying
codes for displaying in calendar
codes for displaying in calendar  can i get jsp codes for displaying comments, when the pointer is placed over the particular date in calendar
Comparison of corresponding rows in a DB
Comparison of corresponding rows in a DB  How to compare corressponding rows in a database using Java????? ex...!!! Thankin u
ModuleNotFoundError: No module named 'rows'
ModuleNotFoundError: No module named 'rows'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'rows' How to remove the ModuleNotFoundError: No module named 'rows' error
Grid rows delete issue
Grid rows delete issue  I have a grid having rows with Remove button to remove rows,But we also havae an facility to remove those rows on onchange event of dropdown also,so if we delete middle row and then remove all rows
(Displaying a calendar in GUI
(Displaying a calendar in GUI  (Displaying a calendar) Write a program that displays the calendar for the current month, as Use labels, and set texts on the labels to display the calendar."The Calendar and GregorianCalendar
autocomplete displaying multiple fields
autocomplete displaying multiple fields  How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box
Displaying date in the preciding code
Displaying date in the preciding code  while deploying the Bill date field on this page are empty though it should be displayed String userName = request.getParmeter("userName"); String custId = request.getParameter("customerId
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button. The values will be entered in this empty row. I have searched on this but could
Displaying file from database
Displaying file from database  I have list of files in my database. I want to display these files in browser according to the input. My need is like google search result. when i click on the link it should display
Displaying error on the Same form
Displaying error on the Same form  I want to display the errors on the same form(Top of the form) after validation. I am used Div element and Table to display the error messages. It is working properly. But those error messages
Displaying files on selection of date.
Displaying files on selection of date.  Hi, I am developing a GUI, where i select from and to date. On selection of from and to date the GUI should show the particular txt files of the selected date. I want the java logic
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
Dyanmically Adding Rows
Dyanmically Adding Rows  Hi sir Am doing project in that i need to add date picker in dynamically adding rows but the dates are storing in first test... rows in HTML table </TITLE> <link rel="stylesheet" type="text/css
Dyanmically Adding Rows with Date Picker
Dyanmically Adding Rows with Date Picker  Hi Sir, I am doing a project in that i need to add rows dynamically with date picker inside row, send me code as soon as possible. Regards, Santhosh
Data displaying with limited records in jsp
Data displaying with limited records in jsp  How to display table with limited 10 records , after clicking next button another 10 records from database upto last record please help me
Displaying Error pages in results tree in jmeter
Displaying Error pages in results tree in jmeter   Displaying Error pages in results tree in jmeter
Php Sql num rows
Php Sql num rows This example illustrates how to find number of rows... and find the number of rows of the table by mysql_num_rows methods. The output...);   $num_rows = mysql_num_rows($result);   
Uploading a software and displaying it on the jsp page
Uploading a software and displaying it on the jsp page  I have a Downloads page in my website, I want it to display the name of softwares as soon as it is uploaded in the backend by the administrator. And the admin may be a non
Displaying database values in pdf format
Displaying database values in pdf format  Hi All, I am developing a struts application.I am having one registration form when i am submitting the form the values are stored in database,the database name is registration
MySQL Affected Rows
MySQL Affected Rows This example illustrates how to show the affected rows... rows affected (0.08 sec)   Here update a table "...; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0
JavaScript Hide Table Rows
JavaScript Hide Table Rows...; In this section, you will learn how to hide table rows using JavaScript... object grabs the id of the table. Then we have determined the length of rows
Php Sql Number of Rows
Php Sql Number of Rows  This example illustrates how to count the rows... of rows of the table. To find the number of the rows we use the mysql_num_rows..._rows($res);     print("$number_of_rows rows 
displaying a physical webpage with frames in iframe
displaying a physical webpage with frames in iframe  i have iframe in my webpage, i have done the coding part for browsing the folders and viewing...="sss"><%=s%></a> <% } %> mycode for displaying
return all rows mysql php
return all rows mysql php  How to find or return results that are not available in another table .. using join method in PHP and MYSql.   SELECT * FROM Declined LEFT JOIN Request ON Declined.RequestID
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
reading and displaying svg file through java
reading and displaying svg file through java  sample program for reading a svg file
Displaying calendars - Java Interview Questions
Displaying calendars  Write a program that prompts the user to enter the year and first day of the year, and displays the calendar table for the year on the console. For example, if the user entered the year 2005, and 6