Home Answers Viewqa JSP-Servlet Fetch the data using jsp standard action

 
 


Abhishek Ghosh
Fetch the data using jsp standard action
2 Answer(s)      10 months ago
Posted in : JSP-Servlet

I want the code of fetch the data from the database & show in a jsp page using jsp:usebean in MVC model 2 architecture. Suppose after login a user can view his/her details which he entered at the time of registration.

View Answers

July 6, 2012 at 3:12 PM


Here is an application that retrieves the data from the database through java bean and display it in jsp page through servlet.

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>

For more information, visit the following link:

http://www.roseindia.net/jsp/servlet-jsp-data-list.shtml


July 7, 2012 at 1:09 AM


In the beandata.jsp you are using scriptlet tag(<% %>).But I am wanting this should be done using jsp:usebean..means scriptless jsp..How can I do that? Thanks in advance









Related Pages:
Fetch the data using jsp standard action
Fetch the data using jsp standard action  I want the code of fetch the data from the database & show in a jsp page using jsp:usebean in MVC model... that retrieves the data from the database through java bean and display it in jsp page
Standard Action "jsp:param"
Standard Action <jsp:param> In this Section, we will discuss about "jsp:param" standard action & their utilization with a example... by using <jsp: forward> tag. Inside this tag we have used the tag <jsp
Standard Action "jsp:plugin"
Standard Action <jsp:plugin> In this Section, we will discuss about standard action "jsp:plugin" & their implementation using a example. The <jsp:plugin> action is use to download a plugin (an Applet or a Bean
standard action - JSP-Servlet
or a standard tag. For Example : Action may display an output or write some value... has attributes with their values. Some Standard action tags: :- The forward action passes the request to another page,page may be a html page or jsp page
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <...; Location Fill Up Your Details <center> <form action...; JSP Page View Your Location Enter
JSP Standard Actions
JSP Standard Actions In this section, we will learn about JSP standard Action & their elements with some examples. JSP Standard action are predefined... at the exact time the JSP page is requested by a browser. An action can, for instance
JSP Standard Action 'jsp:useBean'
JSP Standard Action <jsp:useBean> This action let you use java bean in a JSP page. This action instantiates or locates a Bean with a specific name... standard Actions :<jsp:setProperty> & <jsp:getProperty>
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  hello!!! I am building a attendance sheet in which, I am getting data from one jsp form and want inserting it into my mysql database table. but i am having
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
JSP Standard Actions 'jsp:setProperty' & 'jsp:getProperty'
Source code See Also :(click below) JSP Standard Action <jsp...JSP Standard Actions <jsp:setProperty> & <jsp:getProperty>...; <h3><strong>EXAMPLE OF JSP:USEBEAN STANDARD ACTION<
Action Tag (Data Tag) Example
Action Tag (Data Tag) Example      ... tag that is used to call actions directly from a JSP page by specifying the action... page using <s:action> tag as shown in the success.jsp page. The action
how to fetch data fron facebbok using spring batch and hibernate ?
how to fetch data fron facebbok using spring batch and hibernate ?  how to fetch data from facebbok using spring batch and hibernate ? Means i have to get all details of data from one source like facebook using id ans save all
JSP Action Tag
JSP Action Tag   Defined JSP Action Tag ?   Action tag... JSP action tags to either link to a Java Bean set its properties, or get its properties. syntax of Action Tag : <jsp:action attributes /> The most
spring standard tag libraries
spring standard tag libraries  hello sir please tell me how to write the jsp in Spring frame work using spring standard tag libraries
Data fetch from multiple SQL tables - Hibernate
Data fetch from multiple SQL tables   I am in the process of writing my first hibernate application. I have a sql query that fetches data from multiple tables using left and right outer joins. I need to convert this JDBC data
JSP Get Data Into Dropdown list From Database
about how to fetch data dynamically into the dropdown list in JSP... fetching of data into the dropdown list in JSP using Eclipse IDE and the Tomcat 7... data from the database and set it into the dropdown list in JSP using MySQL
Select tag to fetch data from oracle database
Select tag to fetch data from oracle database  I created a select box having more than one menus in the select box such as regnno, address and name...?? If using strut it has to be completed then also plzzzz tell me
PDO Fetch Into
PDO Fetch Into: Like in the previous tutorial, we will deal with OOP concept in this tutorial. In PHP PDO::FETCH_INTO is a constant which allows us to fetch the data from an existing database into an instance or object of a class
SQL fetch value
SQL fetch value  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M
Action tag - JSP-Servlet
action="services.html " but it only shows html page bt does not submit my data... sending data insert action code...Action tag  Hello, I want to help ....i hav one feedback form
Fetch logged in username in Spring Security
Fetch logged in username in Spring Security In this section, you will learn to fetch the current logged in username in Spring Security. If you are not well... in user's username, which are given below : Using SecurityContextHolder
reading data using struts and jsp java
reading data using struts and jsp java  how can i read data entered by user into a textbox (jsp page) into struts action class ex emp id,so that after reading emp_id it can be read into struts action class for retrieving other
Sending large data to Action Class error. Struts code - Struts
Sending large data to Action Class error. Struts code  I have a jsp..., SrideviMannem) in your D drive. 3. Maintain all your data, documents, projects...' like srideviManname in MySQL using SQLYog.Spend one day to get ready
Accessing Jqxgrid data in Controller layer using JSP
Accessing Jqxgrid data in Controller layer using JSP  I am using Keyboard Navigation jqxgrid. I am able to bind the grid by passing data from controller layer using JAVA. What i actually require is to fetch the data which
JDBC Fetch
, the System.println print the fetch data from database. The code illustrates... JDBC Fetch       The Tutorial describe you a code that fetch the elements from a database. In this Tutorial
PDO Fetch Execute
PDO Fetch Mode: We have studied before in the earlier tutorials that how to connect with a database and how to fetch data from the tables, in many times we... a technique called FETCH, which is used with the PDOStatement object. PDO
PDO Fetch Object
PDO Fetch Object: This is another way to access the data of a table, accessing fields as object. By using this  method we get the result set...;query($sql); $obj=$stmt->fetch(PDO::FETCH_OBJ); echo $obj->name."
PDO Fetch Lazy
PDO Fetch Lazy: PDO::FETCH_LAZY is the combination of PDO::FETCH_OBJ and PDO::FETCH_BOTH. It displays the query which has been made along with the object... student"; $stmt=$dbh->query($sql); $obj=$stmt->fetch(PDO::FETCH_LAZY); print
PDO Fetch Num
PDO Fetch Num: We've discussed in the previous tutorial about PDO::FETCH... index of the result unlike the PDO::FETCH_ASSOC which returns the name...;query($sql); $result=$stmt->fetch(PDO::FETCH_NUM); echo "<table
Understanding Struts Action Class
Class and forward a jsp file through it.  What is Action Class? An Action... the parameterized class to Action Form using the execute() method. The return... Understanding Struts Action Class   
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
how to fetch data from servlet ????
how to fetch data from servlet ????  how to fetch data from servlet
PDO Fetch Both
PDO Fetch Both: In the previous two examples we have seen the two methods... type), PDO provides the solution as PDO::FETCH_BOTH produces, with the help of this function we can achieve both type of output. PDO::FETCH_BOTH produces both
How To Fetch Data From Database Into JTextArea
How To Fetch Data From Database Into JTextArea In this section we will read about how to get the data from database table into JTextArea... given which will demonstrate you about how to fetch data and displayed
PDO Fetch Class
PDO Fetch Class: Using PDO::FETCH_CLASS we can map the fields of a table as properties (fields/variables) of a class. With the help of this method we can...;fetchALL(PDO::FETCH_CLASS,'employee'); foreach($obj as $emp){ echo $emp
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... example which lets you understand to fetch data from database in JSP
Displaying grouped data using Action script in AdvancedDataGrid
Displaying grouped data using Action script in AdvancedDataGrid: In this example you can see how we are create a Grouped Data using Action script...:Script> <s:Panel title="Displaying grouped data using
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <..."; // declare a connection by using Connection interface
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <...*; import org.apache.struts.action.*; public class SearchAction extends Action
Struts(1.3) action code for file upload
application using HttpUrlConnection. How can i write my struts(1.3) action code to handled Multipart form data. I used FormFile and is working fine with struts jsp...Struts(1.3) action code for file upload  Hi All, I want to upload
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title and data and each column has 10 enteries. I have a jsp page on which i want
jsp to struts 2 action conversion problem - Struts
jsp to struts 2 action conversion problem  i have one jsp page that includes 3 other jsp pages(using RequestDispactcher).how to convert that jsp page to a struts2 action?among that one jsp page is wrritten using jpivot,wct tags
Sorting data in a jsp using a servlet while implementing comparable - JSP-Servlet
Sorting data in a jsp using a servlet while implementing comparable  ... for displaying them in the jsp: 1. Universal Books Home Page 2. 3. 4... at line 14 of the jsp code. I also want it to implement comparable to use
How to retreive data by using combo box value - JSP-Servlet
How to retreive data by using combo box value  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use to get values from
No action instance for path
No action instance for path  <%@ taglib uri="http...; <body bgcolor="white"> <html:form action="/FileUploadAndSave" method="post" enctype="multipart/form-data"> <table>
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from the database using servlet on the jsp page and there is checkbox corresponding each row but the problem is that i am not fetching data in any textboxes so how
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
data update
the data and edit it based on subjectcode(varchar)this should be done using jsp...data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit
data update
the data and edit it based on subjectcode(varchar)this should be done using jsp...data update  sir, I have a table consist of huge data.I have displayed that data in table format be side of a table an edit button which will edit

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.