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



Home Answers Viewqa Java-Beginners how to set the values in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


subangkottur
how to set the values in jsp
1 Answer(s)      3 years and 7 months ago
Posted in : Java Beginners


how to set the values text boxs in jsp frm dbase via servlet


Advertisement
View Answers

May 14, 2011 at 10:45 AM


1)Servlet.java:

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

public class Servlet extends HttpServlet{
    protected void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException{
        form.EmpBean p = new form.EmpBean();
        List 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){}
        req.setAttribute("data", list);
        RequestDispatcher rd = req.getRequestDispatcher("/jsp/data.jsp");
        rd.forward(req, res);
    }
}

2)data.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"><input type="text" value="<%=itr.next()%>"></td>
        <td width="168"><input type="text" value="<%=itr.next()%>"></td>
        <td width="168"><input type="text" value="<%=itr.next()%>"></td>
        <td width="168"><input type="text" value="<%=itr.next()%>"></td>
</tr>
        <%}%>
</table>
</body>
</html>


Related Tutorials/Questions & Answers:
how to set the values in jsp
how to set the values in jsp  how to set the values text boxs in jsp frm dbase via servlet
how to set values in object using java and what are the ways?
how to set values in object using java and what are the ways?  How to set values in object using java ?what are the ways
Advertisements
how to set time in jsp page
how to set time in jsp page   I need code for set the time in jsp code .iam using struts frame work back end oracle 10g ide is eclipse 6.0
how to set values from parent page to iframe in javascript
how to set values from parent page to iframe in javascript  how to set values from parent page to iframe in javascript pls reply me as possible as I am in great trouble
How to get a values - JSP-Servlet
How to get a values  Dear sir, I have one input text field and one submit button .Within one file how to get a values within a same jsp. Thanks and Regards Harini Veerapur.  Hi Friend, Try the following
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java?  I have two tables Slink and Locate Slink has column name Slinkid ,locate.... how can i do
how to store the REsult Set values in array and loop through it in java?
how to store the REsult Set values in array and loop through it in java?  I have two tables Slink and Locate Slink has column name Slinkid ,locate.... how can i do
How to get a values - JSP-Servlet
getting a null value aprt from a attachmented file,so how to get a other values...How to get a values  Dear sir, I have a one form... When i submit a form ,inother jsp i.e
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
how to insert values from jsp into ms access
how to insert values from jsp into ms access   how to insert values using jsp into ms access database
How to carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using the below code I am able to carry the username to a JSP (single value... needs to be carried from my servlet to a JSP. How do I do
How to pass multiple values from a servlet to JSP?
How to pass multiple values from a servlet to JSP?  hi, I want to pass multiple values form a servlet to JSP. Hw do i do that? I am able to send one...) values
set the arraylist values - Struts
set the arraylist values   ResourceIdleReport.jsp <
how to get a values from processRecord - JSP-Servlet
how to get a values from processRecord  dear sir, i have a problem in getting a values from java to jsp.Here jsp is used to read a excel sheet that intern call a java program so i want a column values i.e a column contains
how to store a dynamic values - JSP-Servlet
how to store a dynamic values  Dear sir, i have a ArrayList in that i have stored a values from a excel sheet specified column values and i... and bonus is ~5 . Thanks Hr in another arraylist i have a values ~2,~3
How to Sort Column values of a jsp table - JSP-Servlet
How to Sort Column values of a jsp table  Hi Friend Please help me. I am displaying reultset values on multiple jsp page. I want to sort selected column values on every page onclick of an event its very urgent pleasehelp
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file  Hi am new to java. i need to create... a jsp file which contains a textbox, name issuedescription. when user types
how to generate automatic bill based on selected values using jsp/javascript?
how to generate automatic bill based on selected values using jsp/javascript?  how to generate automatic bill based on selected values using jsp/javascript
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how... to display books based on either bookname or authorname, for this i created one jsp page
how to Use jsp:setProperty to set one bean in other bean while to be set bean is of type java.util.List<beantype>
how to Use jsp:setProperty to set one bean in other bean while to be set bean... here, But I am not getting how do I set the value of chapters properties...; private int numOfPages; // Getters and Setters I have a single jsp
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... sample code for how to retrive array values from html to jsp.   hi friend... it into jsp. Means i just want to retrieve values from html form containing array
how to read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare with database using jsp coding i.e, if i have 6(assetid,assetname,serialno,cubical
How to store values in a database using JSTL? - JSP-Servlet
How to store values in a database using JSTL?  I want to store values in a database... How can i store in database? Here is my code... This wil extract details and displays in a table format... Now i want to store these values
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
how to set break in jasper report using ireport - JSP-Servlet
how to set break in jasper report using ireport  hai i have one doubt pls help , how to set page break in jasper with ireport i need urgently pls help me  In iReport3.0.0 - go to view->report group ->new : check
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I used your code for getting a values,i used the fllowing function... values and also the file is not uploading the content type in other jsp it is showing
please help me how to set up Netbeans for JSP
please help me how to set up Netbeans for JSP   Hi roseindian.net, the following page is what i have seen when i run jsp project.What I can do,please help me.We are ready to do INDUSTRIAL PROJECT by JSP. Thank you. ERROR
how to pass the mutiple values from <Ui:datagrid hyperlink - JSP-Servlet
how to pass the mutiple values from    I am getting the error when passing the values from this way emp2=${employee.lastName1} & name=${employee.firstName.How to pass the values from hyperlink in column
how to set background image
how to set background image  how to set image in background in that image i want over lay text how it possible in jsp? using flash image how it is overlayed in jsp page? thanks
Advertisements
 

 

 

DMCA.com