Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts Java Answers

Have Programming Question? Ask it here!
 
 
 


naidu
Java Answers
1 Answer(s)      3 years ago
Posted in : Struts


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

Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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 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
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
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
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
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
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
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
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
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
java - Java Beginners
java  simple java program questions with answers
java
java  pls send me some java basic interview questions with 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
Question Answer
, please follow these steps: Only post your Java or Open Source or technical... and email address is mandatory for the users. The query relating to Java or java relating fields will only be responded. Posting filthy
java interview question and answer - Java Interview Questions
java interview question and answer   sir, i want one mark java interview question and answers
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
hint - Java Interview Questions
hint  Dear roseindia, i want the java interview question and the corresponding question answers.   Hi Friend, Please visit... of interview questions and their answers. Thanks  thanks for your
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
AES decryption in Java
AES decryption in Java   AES decryption in Java with password ?    http://www.roseindia.net/answers/viewqa/Java-Beginners/26020-AES...; http://www.roseindia.net/answers/viewqa/Java-Beginners/26020-AES-Decryption
Java/PHP Developer
Java/PHP Developer  Hi, can u help me with, question from a text file and answers from another text file with check box
JAVA connection pooling - Java Interview Questions
JAVA connection pooling  how to do JDBC connection pooling in Apache...://www.roseindia.net/jsp/jspfundamentals.shtml http://www.roseindia.net/answers/viewanswers/3338.html http://www.roseindia.net/answers/viewanswers/2838.html
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
java regular expression
java regular expression  hi i need java expression which allows all characters with minimum 2 characters and maximum 20 characters in answers field after selecting security questions
java - Java Beginners
Installing Java   How can i install java on my system and what i need to download ...also from where i can download?  Hello,Please check the url http://www.roseindia.net/answers/viewanswers/328.htmlThanks
java beginner
java beginner  Write a program that will grade the students quiz... the user to enter the student answers to be checked and show the number of right answers and the final grade as a percentage. The program will ask if the user want
java or 3d
java or 3d  can we use of 3d in core java? if yes pls tell me a demo example of 3d java. thanks...   Have a look at the following link: http://www.roseindia.net/answers/viewqa/Java3D/8406-java.html
java beginners - Java Beginners
java beginners  pl. let me know the answers of the following questions : 1) A program is unable to create objects of a class declared globally. what could be the problem wtih this construcotr 2) what is the benefit
java - Java Beginners
java   Thanku for posting answers for my questions. how to create reports in java & which tools are used for this. how to edit some fields in reports pls give me answer it is very urgent for me i will be thankful to you
JAVA - Java Interview Questions
JAVA  i need objective Questions and answers ( with 4 or 5 choice) in JAVA. Can anyone help me?   H1!! pl. mail your email id to asciimails@gmail.com. I will send you within 2-3 days. Krishna
about c and java
about c and java   i need java and c language interview and objective questions with answers for the fresher.please provide to me   Please visit the following links: http://www.roseindia.net/java/ http
java - Java Interview Questions
Java Abstract Class and Interface Info  What are the Java Abstract... read the given tutorial. http://www.roseindia.net/java/master-java/abstract... of Interface"! http://www.roseindia.net/answers/viewanswers/244.html
important topics to prepare for java interview
interview questions from the given link: Java Interview Questions and their Answers...important topics to prepare for java interview  hi friends can anyone tell what are the important topics to prepare for java interview????  
java project - Java Beginners
java project  Can u pls suggest me any ideas for my B.E project? It's urgent... Front end---Java Back end----Oracle IDE---------Netbeans5.5.... ***********************Thanks for the previous answers
JAVA - Java Beginners
JAVA  Dear Sir, Kindly arrange to send urgently the answers to the following in JAVA rega1.JAVA rding True or False, please. 1. JAVA is pure object oriented Language .. True/False 2. Private number of your Class
JAVA - Java Beginners
JAVA  JAVA Expert:N.SATHYANANDA Dear Sir, Kindly arrange to send urgently the answers to the following One Question in JAVA regaarding True or False, please. 1. Private Member of a Class can be accessed by its Sub
Advertisements
 

 

 

DMCA.com