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



Home Answers Viewqa Java-Beginners jsp using Beans

Have Programming Question? Ask it here!
 
 
 


suman tipparapu
jsp using Beans
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


public class Empbean
{
   int empno;
   String ename;
   float sal;
   public Empbean()
    {
    }
    //set of set methods
    //set get methods
    public void getDbConnection() //readable method
    {
        //i get the oracle connection here
        PreparedStatement pst=con.prepareStatement("insert into emp values(?,?,?)")
    }
    public void getDbValues()//readable method
    {
        // set the values for positional params
    }
}

i need jsp program for above bean class


Advertisement
View Answers

January 11, 2011 at 6:07 PM


Hi Friend,

Try the following code:

1)EmpBean.java:

package form;
import java.sql.*;
import java.util.*;
public class EmpBean {

public List dataList(){
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"));

}
}
catch(Exception e){}
return list;

}
}

2)BeanInServlet.java:

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

public class BeanInServlet extends HttpServlet{
    protected void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException{
        form.EmpBean p = new form.EmpBean();
        List list=p.dataList();

        req.setAttribute("data", list);
        RequestDispatcher rd = req.getRequestDispatcher("/jsp/beandata.jsp");
        rd.forward(req, res);
    }
}

3)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>

Thanks



Related Tutorials/Questions & Answers:
jsp using Beans
jsp using Beans  public class Empbean { int empno; String ename... need jsp program for above bean class   Hi Friend, Try the following...); RequestDispatcher rd = req.getRequestDispatcher("/jsp/beandata.jsp"); rd.forward
Using Beans in JSP. A brief introduction to JSP and Java Beans.
USING BEANS IN JSP      ....  JSP?s provide three basic tags for working with Beans..., it is very easy to connect to databases using beans rather than
Advertisements
Register page using servlets,jsp and java beans
Register page using servlets,jsp and java beans  i want code for register page using jsp,serlets and java beans.iam getting error for my code in java...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml Thanks
Error in using java beans - JSP-Servlet
Error in using java beans  I am getting the following error when I run the jsp code. type Exception report message description The server...: Unable to load class for JSP
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
how to generate PDF file using JSP with net beans
how to generate PDF file using JSP with net beans  I am trying to generate PDF file using JSP. I even added itext5.0.6 jar file in library. It shows...\apache\jsp\hh_jsp.java:8: package com.lowagie.text does not exist import
java beans code in jsp - WebSevices
java beans code in jsp  can you tell me how to use java beans in jsp... summary page and funds transfer page using java beans.   Hi Friend...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml Hope that it will be helpful
jsp,beans,jdbc - JSP-Servlet
jsp,beans,jdbc  I have created jsp page and corresponding servlet... database for specific date .this data is retrived on jsp page by beans.i use beans... in jsp how to show field sum on jsp page plz guide   Hi friend
java beans - JSP-Servlet
the problem visit to : http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks
calling java beans - JSP-Servlet
calling java beans  Sir, I want to know where to place the java beans java file and class file inside tomcat web server. and how to call them from jsp file.  Hi Friend, Java Bean is placed in classes\form
How to use Java Beans in JSP?
How to use Java Beans in JSP?  Hi, I have developed a employee bean...; ..... } Please tell me how I can use Employee Java bean in JSP page? Thanks   Hi, Read at Java Bean in JSP. Thanks   hi dude your qus
jsp directory created in net beans but not able to access
jsp directory created in net beans but not able to access  File f...("/") + "artists/" +username + "/images"); images.mkdir(); i am using this code... trying to display image i am not able to display i am using netbeans and using
java Using net beans - Java Beginners
java Using net beans  Dear Sir, I just like to ask why i cant add a data to the answer you have given me last time where i have to pick the data of the student like id , name , class , age & address using netbeans jframe then i
java Using net beans - Java Beginners
java Using net beans  Dear Sir, I just like to ask why i cant add a data to the answer you have given me last time where i have to pick the data of the student like id , name , class , age & address using netbeans jframe then i
java Using net beans - Java Beginners
java Using net beans  Dear Sir, I just like to ask why i cant add a data to the answer you have given me last time where i have to pick the data of the student like id , name , class , age & address using netbeans jframe then i
sample application using hibernate and wicket framework in net beans IDE
sample application using hibernate and wicket framework in net beans IDE  where can i get sample applications/ projects using hibernate and wicket framework in net beans IDE
how to run audio files in net beans using j2me
how to run audio files in net beans using j2me  i am running the audioMidlet in net beans. Now where should i place the .wav files inorder to play them
to access value of drop down value in beans when dropdown is populated using ajax
to access value of drop down value in beans when dropdown is populated using ajax  i want to access value of dropdown box in beans .. and this drop down was filled using ajax. plz help
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
java beans - Java Beginners
java beans  how and where are java beans implemented  Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/using-bean-counter.shtml http://www.roseindia.net/jsp/java-bean-example-jsp.shtml
Enterprise Beans
that signifies the use of enterprise beans. Applications developed by using... Enterprise Beans       Enterprise beans are the Java EE server side components that run inside the ejb container
Implementing Bean with scriptlet in JSP
page We can use all of the JSP coding while using Java Beans in a JSP page... example will describe you to use JSP Scriptlet in a JSP page using Java Beans...;/jsp:useBean>  And by using scrpitlet in JSP we are calling insert
Java Beans
Java Beans  hii What is Java Beans?   hello,, A Java Bean is a reusable software component that can be manipulated visually in a builder tool
Developing Distributed application using Enterprise Java Beans, J2EE Architecture, EJB Tutorial, WebLogic Tutorial.
) Enterprise Java Beans (EJB) Java Server Pages (JSP) Java Servlets... applications. Applications written using the Enterise JavaBeans
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
net beans
net beans  how to calculate electric bill,units,load in net beans and how to insert this calculated bill ,unit and load into database and how this calculate value comes on GUI
NET BEANS
NET BEANS  My problem is when i am going to install net beans then it showing the problem that JDK6 or JDK5 is required for installing net beans IDE,but in actually I've already installed the jdk5,I do not know why
Java Beans pls!! - Java Beginners
Java Beans pls!!  hello,, can someone give me a simple program of java beans, and Jsp. pls.. im begging you guys.. i really need it!! plss.. thanks.../using-bean-counter.shtml http://www.roseindia.net/jsp/usingbeansinjsp.shtml
Is JSF using JSP?
Is JSF using JSP?  Is JSF using JSP
report generation using jsp
report generation using jsp  report generation coding using jsp
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
Connect from database using JSP Bean file
Connect from database using JSP Bean file... the Presentation logic. JSP provides three basic tags for working with Beans...;/title></head> <body bgcolor="#ffccff"> <h1>JSP using
net beans
net beans  Write a JAVA program to validate the credit card numbers using Luhn Check algorithm. You will need to search the Internet to understand how the algorithm works.   Hi Friend, Try the following code: import
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
ScatterPlot using jsp
ScatterPlot using jsp  hi, can anybody provide me code for ScatterPlot using jsp. thanks
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
datasource in jsp using struts
datasource in jsp using struts  how to get the datasource object in jsp.datasource is configured in struts-config.xml
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
video uploading using jsp
video uploading using jsp  how to upload a videos in web page using jsp   Hi, You can upload your video with the help of JSP file upload code. Once file is upload you can play using any video player. Get the code
generate pdf using jsp
generate pdf using jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
NET BEANS - IDE Questions
NET BEANS  hi i am new to net beans and wants to use net beans 6.5 can any body tell me how can i learn completely about it..if any body have... sending a link where you can see how to create a visual-jsf application using
Advertisements
 

 

 

DMCA.com