Home Answers Viewqa Struts Java Answers

 
 


naidu
Java Answers
1 Answer(s)      a year and 9 months ago
Posted in : Struts

How to Dispaly  databsae records in my jsp page using collections  Java Class
View Answers

August 24, 2011 at 10:24 AM


1)BeanServlet.java:

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

public class BeanServlet extends HttpServlet{
    protected void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException{

ArrayList list=new ArrayList();
try{
     Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from employee");
           while(rs.next()){
               list.add(rs.getString("name"));
               list.add(rs.getString("address"));
               list.add(rs.getString("contactNo"));
               list.add(rs.getString("email"));
}
req.setAttribute("data", list);
        RequestDispatcher rd = req.getRequestDispatcher("/jsp/beandata.jsp");
        rd.forward(req, res);
}
catch(Exception e){
}
    }
}

2)beandata.jsp:

<%@page language="java" import="java.util.*" %>
<html>
<body> 
<table border="1" width="303">
<tr>
<td width="119"><b>Name</b></td>
<td width="168"><b>Address</b></td>
<td width="119"><b>Contact no</b></td>
<td width="168"><b>Email</b></td>
</tr>
<% Iterator itr;%>
<% List data=(List)request.getAttribute("data");
for(itr=data.iterator(); itr.hasNext(); ){
%>
<tr>
<td width="119"><%=itr.next()%></td>
<td width="168"><%=itr.next()%></td>
<td width="168"><%=itr.next()%></td>
<td width="168"><%=itr.next()%></td>
</tr>
<%}%>
</table>
</body>
</html>









Related Pages:
Java Answers
Java Answers  How to Dispaly databsae records in my jsp page using collections Java Class   Visit Here
Java Answers
Java Answers  How to Dispaly databsae records in my jsp page using collections Java Class   Visit Here
Java Answers
Java Answers  How to Dispaly databsae records in my jsp page using collections Java Class   Visit Here   For getting records from database to java collections you want to do following steps. 1.Declare
Java Answers
Java Answers  How to Dispaly databsae records in my jsp page using collections Java Class   1)BeanServlet.java: import java.io....){ } } } 2)beandata.jsp: <%@page language="java" import="java.util.*" %> <
Java interview questions and answers
Java interview questions and answers   what is garbage collection? What is the process that is responsible for doing that in java? Ans.Reclaiming... in Java? Ans. Runtime.getRuntime().exec(â?¦.) 5.What is the basic difference
oop answers - Java Beginners
. Write a Java statement that prints the values of the instance variables of x. i. Write a Java statement that creates the XClass object t and initializes
String Exercises 1 - Answers
Java: String Exercises 1 - Answers Answers to the String Exercises 1. 3 -- s refers to exactly the same string as a. ERROR -- t is a local variable, and it must be assigned a value first. "1abc" -- + means concatenation
Questions and Answers Help
://www.roseindia.net/answers/viewqa/Java-Beginners/11976-Java-Hello-World-code...Questions and Answers Help      ... programmers to give precise answers to your question. Describe your question
Questions and Answers Help
://www.roseindia.net/answers/viewqa/Java-Beginners/11976-Java-Hello-World-code...Questions and Answers Help      ... programmers to give precise answers to your question. Describe your question
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... jsp page, server can develop a .java file for a particular jsp page or not? What
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... jsp page, server can develop a .java file for a particular jsp page or not? What
Software Questions and Answers
from within Java program. JMS - JMS questions and answers...Software Questions and Answers       View Software Questions and Answers online Discuss Software
Java: Boolean Expression Answers
Java NotesBoolean Expression Answers Name ______________________ Assume the following: int i, j, k; boolean b; k = 10; j = 6; b = true; Give the values of the following expressions, or illegal. 1trueb 2false!b 3true!!!!!!b 4trueb
Core Java Interview questions and answers
Core Java Interview questions and answers  ... and answers in one place. These Core Java Interview Questions are supported... the answers. We are constantly trying to provide best Core Java Interview questions. You
Java: Numeric Expression Answers
Java NotesNumeric Expression Answers Name ______________________ Assume the following: int i, j, k; byte by; double d; float f; k = 10; j = 6; f = 3.9F; d = 6.2; Give the values of the following expressions, or illegal. 171 + 2 * 3
Software Questions and Answers
the answers of the questions asked. JavaMail - Java API to send...Software Questions and Answers View Software Questions and Answers online Discuss Software development questions, ask your questions and get answers
java apptitude question and answers - Java Beginners
java apptitude question and answers  i want java appititude question and answers  Hi Friend, Please visit the following link: http://www.roseindia.net/interviewquestions/ Thanks
Plz give the answers - Java Interview Questions
), is the number itself. Write a JAVA program to find all perfect numbers between 2... information,Examples and tutorials on java visit to : http://www.roseindia.net/java/ Thanks
Java Programming: Chapter 1 Quiz Answers
Sample Quiz Answers For Chapter 1 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 1 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 2 Quiz Answers
Sample Quiz Answers For Chapter 2 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 2 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 3 Quiz Answers
Sample Quiz Answers For Chapter 3 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 1 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming, Chapter 12 Quiz Answers
Sample Quiz Answers For Chapter 12 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 12 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question
Java Programming: Chapter 6 Quiz Answers
Sample Quiz Answers For Chapter 6 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 6 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 7 Quiz Answers
Sample Quiz Answers For Chapter 7 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 7 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 5 Quiz Answers
Sample Quiz Answers For Chapter 5 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 5 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 10 Quiz Answers
Sample Quiz Answers For Chapter 10 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 10 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question
Java Programming: Chapter 9 Quiz Answers
Sample Quiz Answers For Chapter 9 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 9 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 4 Quiz Answers
Sample Quiz Answers For Chapter 4 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 4 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming: Chapter 8 Quiz Answers
Sample Quiz Answers For Chapter 8 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 8 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question. Question
Java Programming, Chapter 11 Quiz Answers
Sample Quiz Answers For Chapter 11 THIS PAGE CONTAINS SAMPLE ANSWERS to the Quiz on Chapter 11 of this on-line Java textbook. Note that in many cases, there are lots of correct answers to a given question
String Exercise 2 - Answers
Java: String Exercise 2 - Answers Name ______________________ Assume the following:> String s, t, h, a; String n, e; int i; h = "Hello"; s = " How are you? "; a = "abc"; n = null; e = ""; Give the values of the following
Outsourcing - Answers to Critism, Outsourcing Answers Critics
Outsourcing - Answers to Criticism, Outsourcing Answers Critics Introduction As the outsourcing juggernaut rolls on, business analysts have come up with arguments favoring and criticizing it. Cost savings
Question Answer
Java or Open Source or technical problem not comments in this section.... The query relating to Java or java relating fields will only
Question-Answer Guidelines
and get their answers? RoseIndia Q&A service is only for troubleshooting the Java... guidelines: Do this: The user must post the query relating to only Java... to declare theirs' existing and true email addresses in which the answers
plz Help me find the correct programs answers
INDICA" and "TATA NANO" respectively. Plz mail me your answers
Interview Questions and Answers
Interview Questions and Answers   ... that there cannot be just one answer to them. Your answers depend a lot on your particular... such questions, rather than specific answers. Remember, what you say makes only
java - Java Beginners
java  simple java program questions with answers
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1) Write a full program for the bubble sort algorithm. User is required to enter specific input numbers and the program will be able to sort the given numbers
please help me to answers this question about C++.....huuhuhuhu
please help me to answers this question about C++.....huuhuhuhu  1) Write a full program for the bubble sort algorithm. User is required to enter specific input numbers and the program will be able to sort the given numbers
java
java  pls send me some java basic interview questions with answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers  how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
Common Interview Questions and Their Answers.
Common Interview Questions and Their Answers... important part of these is your answers. Also make sure to check how long you speak on each occasion. Do not talk for more than two minutes at a stretch. The answers
Ask PHP Questions
; PHP Questions and Answers Ask PHP Questions and get answers from.... In your questions and answers section you can ask PHP questions and get answers quickly from our users. Our team will also try to provide you
Java
Java  Hoe to convert excel file into postgrey database??   Please visit the following links: http://www.roseindia.net/tutorial/java/poi/insertExcelFileData.html http://www.roseindia.net/answers/viewqa/Java
java
java  Please send me some question and answers regarding interview .....   Hi Anitha, Please go through the below blog, you will get some information related to Java like. http://www.roseindia.net/java/ All
Java
base through java?? so please suggest me java code.   Please visit the following links: http://www.roseindia.net/tutorial/java/poi/insertExcelFileData.html http://www.roseindia.net/answers/viewqa/Java-Beginners/14214-Read-data-from
Java
base through java?? so please suggest me java code.   Please visit the following links: http://www.roseindia.net/tutorial/java/poi/insertExcelFileData.html http://www.roseindia.net/answers/viewqa/Java-Beginners/14214-Read-data-from

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.