Home Answers Viewqa Java-Beginners jsp using Beans

 
 


suman tipparapu
jsp using Beans
1 Answer(s)      2 years and 4 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

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 Pages:
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
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
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
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
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
Pojo and java beans
() method. This request is then send to jsp page. Using the getAttribute() method... class and where we should use beans. We use pojo class to make the object..., you can use POJO class with JSP and Servlets also. Here is an example of POJO
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
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
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
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
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
java beans - JSP-Servlet
the problem visit to : http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks
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
Using Beans And Page Scope
; <title>Using Beans and Page Scope</title> </head> <body> <h1>Using Beans and Page Scope</h1> <jsp...Using Beans And Page Scope     
Using Beans And Session Scope
Using Beans And Session Scope     ...; <html> <head> <title>Using Beans and Session Scope</title> </head> <body> <h1>Using Beans
Using Beans And Request Scope
Using Beans And Request Scope     ...;   <title>Using Beans and Request...;body>   <h1>Using Beans and Request Scope<
Using Beans And Session Scope
Using Beans And Session Scope     ...;   <title>Using Beans and Session...;   <h1>Using Beans and Session Scope<
Using Beans And Application Scope
Using Beans And Application Scope   ...;Using Beans and Application Scope</title>...>Using Beans and Application Scope</h1>  
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
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
EL and Complex Java Beans
. The jsp expression language allows a page author to access a bean using simple syntax.... Using scripting in jsp all the time makes the program difficult to understand...EL and Complex Java Beans      
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
How to access Enterprise Beans
How to access Enterprise Beans In this tutorial you will learn that how to access Enterprise Beans (applicable only to session beans not to message-driven beans) Enterprise beans are accessed by the client in two ways either through
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
Message Driven Beans
Message Driven Beans       Message driven beans are the light weight components used for communication. In message driven beans the messaging service is in asynchronous mode because
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
Types of Enterprise Beans
Types of Enterprise Beans In this section we will discuss about the types of Enterprise Beans. Summarily there are two types of Enterprise Beans... discussing these beans in detail Session Bean A Session bean is a non persistent
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
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
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
Java Beans Books
design software systems using Java Beans, this book will be a valuable resource... Java Beans Books         Java Beans book review The book
Where is servlet log file in net beans?
Where is servlet log file in net beans?  When you use context.log("some string"); then the string get written into the servlet log file. But where is the servlet log file in netbeans? I am using netbeans 6.9. I can't locate
Message Driven Beans
Message Driven Beans       Message driven beans are the light weight components used for communication. In message driven beans the messaging service is in asynchronous mode because
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
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
what is difreence between javabeans and enterprise beans - EJB
, Differences: 1)Java Beans are used for building extendable components and contain... while EJB is designed to work in distributed environment using rmi/iiop protocol... JavaBeans,it is far easier to develop them using the EJB specification instead
Stateful Session Beans Example, EJB Tutorial
;    In this part of Enterprise Session Beans, you will learn how to develop, deploy, and run a simple Java EE application named account using... beans also may: Implement any optional life cycle callback methods
Java programming or net beans - Java Beginners
better. i am using Netbeans IDE.  Hi Friend, Please clarify
Session Beans
Session Beans      ... beans are relatively short-lived components. The EJB container may destroy... Session Bean interacts with the clients as well as with the Entity Beans
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go... visit the following link: http://www.roseindia.net/jsp/using-bean-counter.shtml... created in Java and compiled <%@ page language="java" import="beans" %>
Jakarta Struts & Advanced JSP Course
Form Beans as Mediators Using Reflection and BeanUtils Reusing... Jakarta Struts & Advanced JSP Course   ... Using Struts actions and action mappings to take control of 
linking jsp with database using classes and methods and then access them all in to my jsp page - JSP-Servlet
linking jsp with database using classes and methods and then access them all in to my jsp page  how to connect jsp page with mysql using classes... all with the help of java beans in u'r own jsp page
How to get the output of jsp program using Bean
How to get the output of jsp program using Bean  Hello my Roseindia...; Next i created JSP program for the above one by using Bean and i opened... i created in Java and compiled <%@ page language="java" import="beans

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.