How to connect to dao n bean classes with jsp

How to connect to dao n bean classes with jsp

I have made this edao pkg

package edao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import ebean.Add_Village;

public class AddVillageInfo extends EConnect {
Connection con;

    public boolean save_add(Add_Village ad)
    {
        try{
            con=getConnection();
            Statement st=con.createStatement();
            ResultSet rs1=st.executeQuery("select Id from AddVillageDetails");
            String temp="1";
            while(rs1.next())
            {
                temp=rs1.getString(1);
            }

            temp=String.valueOf(Integer.parseInt(temp)+1);
            PreparedStatement stmt=con.prepareStatement("insert into AddVillageDetails values(?,?,?,?,?,?,?,?,?)");
            System.out.println("start");
            stmt.setString(1,temp);
            stmt.setString(2,ad.getState());
            stmt.setString(3,ad.getDistrict());
            stmt.setString(4,ad.getTehsil());
            stmt.setString(5,ad.getVillageName());
            stmt.setString(6,ad.getSurpanchName());
            stmt.setString(7,ad.getNoOfHouseHolds());
            stmt.setString(8,ad.getNoOfLandSellers());
            stmt.setString(9,ad.getTotalVillageArea());
            System.out.println("Bean set");

            stmt.executeUpdate();
            return true;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.out.println(e);
            return false;
        }
    }

}


**then i have this ebean pkg**

package ebean;

public class Add_Village {
    String Id,State,District,Tehsil,VillageName,SurpanchName,NoOfHouseHolds,NoOfLandSellers,TotalVillageArea;

    public String getId() 
    {
        return Id;
    }

    public void setId(String id)
    {
        Id = id;
    }

    public String getState()
    {
        return State;
    }

    public void setState(String state) 
    {
        State = state;
    }

    public String getDistrict() 
    {
        return District;
    }

    public void setDistrict(String district) 
    {
        District = district;
    }

    public String getTehsil() 
    {
        return Tehsil;
    }

    public void setTehsil(String tehsil) 
    {
        Tehsil = tehsil;
    }

    public String getVillageName() 
    {
        return VillageName;
    }

    public void setVillageName(String villagename) 
    {
        VillageName = villagename;
    }

    public String getSurpanchName() 
    {
        return SurpanchName;
    }

    public void setSurpanchName(String surpanchname) 
    {
        SurpanchName = surpanchname;
    }

    public String getNoOfHouseHolds() 
    {
        return NoOfHouseHolds;
    }

    public void setNoOfHouseHolds(String noofhouseholds) 
    {
        NoOfHouseHolds = noofhouseholds;
    }


    public String getNoOfLandSellers() 
    {
        return NoOfLandSellers;
    }

    public void setNoOfLandSellers(String nooflandsellers) 
    {
        NoOfLandSellers = nooflandsellers;
    }

    public String getTotalVillageArea() 
    {
        return TotalVillageArea;
    }

    public void setTotalVillageArea(String totalvillagearea) 
    {
        TotalVillageArea = totalvillagearea;
    }

}



**how to connect with this edao and ebean pkg with my jsp page**

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%  String state=request.getParameter("state");
    String district=request.getParameter("district");
    String tehsil=request.getParameter("tehsil");
    String villagename=request.getParameter("villagename");
    String surpanchname=request.getParameter("surpanchname");
    String noofhouseholds=request.getParameter("noofhouseholds");
    String nooflandsellers=request.getParameter("nooflandsellers");
    String totalvillagearea=request.getParameter("totalvillagearea");
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AddVillagejsp</title>
</head>

<body bottommargin="2" leftmargin="10" rightmargin="10" topmargin="1">

<table  align="center"  cellSpacing=0  cellPadding=0  width="60%" border=0>
    <tbody>
        <tr>
                <td bgColor="#2a5865" colSpan=1>
                    <IMG height=4 src="images/zero.gif" width=1>
                </td>
        </td>
</tbody>
</table>

<table align="center" width="60%" height="100" >
    <tr>

        <td width="40%" height="100">
                <p align="right" style="margin-top: 0; margin-bottom: 0"> 
                <img src="images/avantha1.jpg" width="520" height="100"></p>
        </td>


            <td width="20%" height="100">
                <p align="right" style="margin-top: 0; margin-bottom: 0"> 
              <img src="images/logo[2].gif" width="200" height="100"></p>
      </td>
  </tr>
</table>

<body style="margin-left: 10pt; margin-right: 10pt; margin-bottom: 5pt"  >

<TD background="images/dot.gif"><IMG height=4 src="images/zero.gif" width=25></TD>
</TR></TBODY></TABLE>
<br>
<table width="60%"  height="40" border="0" cellpadding="6" cellspacing="0" align="center">
    <tbody>
    <tr>
        <td valign="top" align="center" bgcolor="#2a5865"><font class="blackboldtxt"><font color="#ffffff" size=5><b>Add Village Details</b></font></font></td></tr>
        </td>
    </tr> 


<form name="VillageDetailsForm" action="simple.jsp" method="post" onSubmit="return adsvalidate();">
<table width="50%" height="400" bgcolor="#ecf7fb" border="0" cellpadding="0" cellspacing="0" align="center">
<br>
<tbody><tr><td colspan="2" align="center"><font class="textsmallbluenormal"><font color="#333333">All fields marked with <font color="#d36000">*</font> are mandatory.</font></font></td></tr>


<tr>
    <td style="padding-left: 15px; padding-top: 10px;" valign="middle" width="200"><font class="blackboldtxt"><font color="#003e7b">State :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
    <td style="padding-top: 10px;" valign="top">
    <select style="width: 175px; font-family: arial,Verdana,sans-serif; font-size: 8pt;" class="textfiled" name="State" onChange="fillSelectFromArray(this.form.City, ((this.selectedIndex == -1) ? null : residingcity[this.selectedIndex-1]));getLocality();">
    <option value="0" selected="selected"> ---------- Select State ---------- </option>
    <option value="1">Chhattisgarh</option>
    <option value="2">Madhya Pradesh</option>
    </select>
    </td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">District :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="District" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Tehsil/Taluka/Block :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="tehsil" value="">
</td>
</tr>

<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Village :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="VillageName" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Surpanch Name :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="SurpanchName" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">No. Of HouseHolds :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="NumberOfHouseHolds" value="">
</td>
</tr>



<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">No. Of Land Sellers :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="NumberOfLandLosers" value="">
</td>
</tr>



<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Total Village Area :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="TotalVillageArea" value="">
</td>
</tr>


<tr>
                      <td colspan="2" valign="top" align="middle"><br>
                          <input name="file_name" value="newuser" type="hidden">
                          <input name="Country" value="" type="hidden">
                          <input name="reset" src="login.php_files/submit-button.gif" value="Clear" type="reset" width="62" border="0" height="19">
                          Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 
                          <input name="post" src="login.php_files/submit-button.gif" value="Submit" type="submit" width="62" border="0"height="19" onClick='return check(frm)'>
                          Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 
                          <input name="reset" src="login.php_files/submit-button.gif" value="Back" type="reset" width="62" border="0" height="19" onClick="history.go(-1)">              
                     </td>


</tr>

</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<!-- End of New Village Registration -->
<jsp:useBean id="adinfo" class="ebean.Add_Village"></jsp:useBean>
    <% AddVillageInfo ad=new AddVillageInfo();

    ad.setState("state");
    ad.setDistrict("district");
    ad.setTehsil("tehsil");
    ad.setVillageName("villagename");
    ad.setSurpanchName("surpanchname");
    ad.setNoOfHouseHolds("noofhouseholds");
    ad.setNoOfLandsellers("nooflandsellers");
    ad.setTotalVillageArea("totalvillagearea"));    
    boolean b=adinfo.save_add(ad);
    %>
</body>
</html>

it gives an error that it doesnt import my pkg

View Answers









Related Tutorials/Questions & Answers:
How to connect to dao n bean classes with jsp
How to connect to dao n bean classes with jsp  I have made this edao... = totalvillagearea; } } **how to connect with this edao and ebean pkg with my jsp...()); System.out.println("Bean set"); stmt.executeUpdate
DAO Classes
DAO Classes  login page code for Dao classes
Advertisements
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
How to connect to MySQL in JSP?
How to connect to MySQL in JSP?  How to connect to MySQL in JSP..., You can use the Java JDBC code to connect to MySQL database in JSP page. Check the tutorial: Connect JSP with mysql Thanks
ModuleNotFoundError: No module named 'connect-n'
'connect-n' How to remove the ModuleNotFoundError: No module named 'connect-n' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'connect-n'  Hi, My Python
ModuleNotFoundError: No module named 'connect-n'
'connect-n' How to remove the ModuleNotFoundError: No module named 'connect-n' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'connect-n'  Hi, My Python
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 connect jsp to mysql - Java Beginners
how to connect jsp to mysql  I m new in Mysql and JSP i m ceating.java file using bean file for connectivity but i m not able to connect jsp... me hw to conncet jsp with mysql this is connection file package connect
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login 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...; private int numOfPages; // Getters and Setters I have a single jsp (a.jsp) containing input fields for all the 3 classes, and action of that jsp
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before... DSN will get created. 6) Restart your server and run your jsp code. Here is your
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...; <jsp:useBean id="counter" scope="session" class="CounterBean" /> <
how to create bean using jsp and servlet
how to create bean using jsp and servlet  public class SampleBean... the following links: http://www.roseindia.net/jsp/usingbeansinjsp.shtml http://www.roseindia.net/jsp/loginbean.shtml
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
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..." %> <HTML> <HEAD> <TITLE>Use Bean Counter Example <
how to connect the database using hibernet through servlet/jsp through form
how to connect the database using hibernet through servlet/jsp through form  plz give me the reply   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 http://www.roseindia.net/jsf/myfacesspring
Connect JSP with mysql
Connect JSP with mysql : Now in the following jsp code, you will see how to connect with the database. First you need to copy my sql connector jar file... Connect JSP with mysql   
Connect from database using JSP Bean file
Connect from database using JSP Bean file...; is doing the loading of bean file from the classes. <jsp:useBean id....   ADS_TO_REPLACE_1 <jsp:useBean id=?bean name? class=?bean
How to connect
How to connect  how to connect to a remote host using jsp? We need to update files to the database of the application on the local machine from the updated database on our webpage
bean - JSP-Interview Questions
bean  what is use bean in jsp?  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 Hope
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... to write down the classes and methods in the different folder and then call them
RMI n JSP - RMI
RMI n JSP  Hi Friends, First of all let me appreciate ur promptness in delivering answers. Is it possible to make communication between RMI and JSP page ? Thanks
RMI n JSP - RMI
RMI n JSP  Hi Friends, First of all let me appreciate ur promptness in delivering answers. Is it possible to make communication between RMI and JSP page ? Thanks
connect jsp with tomcat - JSP-Servlet
connect jsp with tomcat  hello friends, i have severe problem in making connection between tomcat 6.0.18 and jsp pages.my system configuration... web.xml file.. or put your jsp prg folder in jsp-examples only, you can send
Connect JSP with mysql
how to connect to MySQL database from your JSP code. First, you need to create...) Here is the video tutorial of "How to connect to MySQL Database from JSP... Connect JSP with mysql   
unable to connect to server - JSP-Servlet
unable to connect to server  thank you for the program code... in weblogic/apache servers can any one help me how to do this ?   Hi Friend..., create a web application folder inside the webapps folder and put the jsp file
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used in jsp. As you all know a counter increments the value by one. Here, we will use
how to connect webcam in html
how to connect webcam in html  how to connect webcam in html.emphasized text
drag n drop - JSP-Servlet
drag n drop  I want to implement drag n drop functionality for simple HTML/JSP without using applet,flash or any heavy components.using browse button... using drag and drop mode.when user drag n drop file then display the complete path
jsp and bean problem
jsp and bean problem  Hi i have the following jsp code... Can you plz help me in separating the code to bean? I'm new to bean and need it for my project...Plz help...Its quite urgent... Regards Priya <%@ page import
How to connect with database
How to connect with database  jdbc connection
problem connect jsp and mysql - JSP-Servlet
problem connect jsp and mysql  hello, im getting an error while connecting jsp and mysql. I have downloaded the driver mysql-connector...: org.apache.jasper.JasperException: Exception in JSP: /jsptutorial/testsql.jsp:17 14
how to create a slider on jsp page n slider has values from 0-4
how to create a slider on jsp page n slider has values from 0-4  i want to create a slider on jsp page and slider has values from 0-4   Using the jquery, you can create a slider in jsp. <html> <head> <
How to get Output for a Bean problem
How to get Output for a Bean problem  Hello Kindly tell me a simple Program on Bean to get the Output using JSP code
Assigning a value to JSP variable from a bean class. - JSP-Servlet
Assigning a value to JSP variable from a bean class.  Hi, I want to know how we can assign value to a JSP variable from a Java Bean. I am using Struts, JSTL. Which tags should I use to assign the value. e.g Kindly
how many types of system classes are there?
how many types of system classes are there?  How many types of system classes
how to create classes for lift program
how to create classes for lift program  i would like to know creating classes for lift program
JSP bean get property
JSP bean get property   ... in JSP page. The JSP page uses bean get property and return the value stored... package. class is used to give the reference of the bean class. <jsp
use properties file to connect to the database in jsp..
use properties file to connect to the database in jsp..  How to use properties file to connect jsp code with database ..........   Here is a jsp code that connects to database using properties file. <%@page import
how to create dao
how to create dao   code1: package com.dao; import java.sql.*; import com.beans.*; public class DbAccess { public void createStudent(SampleBean sampleBean) throws SQLException { Connection con=null; try
can pass list of n values in session and get in jsp
can pass list of n values in session and get in jsp  In dao: am geting username,companyname,usertype and set to userBean and add to arraylist...(true); session.setAttribute("currentUser",list); In jsp: <
can pass list of n values in session and get in jsp
can pass list of n values in session and get in jsp  In dao: am geting username,companyname,usertype and set to userBean and add to arraylist...(true); session.setAttribute("currentUser",list); In jsp: <
Implementing Bean with script let in JSP
Implementing Bean with script let in JSP...; This application illustrates how to create a bean class and how to implement it with script let of jsp for inserting the data in mysql table. In this example we create
Need Help-How to store input parameter in DB through Java Bean - JSP-Servlet
Need Help-How to store input parameter in DB through Java Bean  Hello... . jsp:useBean call a property IssueData. this property exist in SimpleBean.java(Its Java Bean) which create a connection from DB and insert the data. At run
Using javabeans to connect mySQL database on a jsp page - JSP-Interview Questions
Using javabeans to connect mySQL database on a jsp page  Hi, Am doing my project and I don't know how to connect a jsp page to a mySQl database...; Connecting a JSP page to MYSQL Database using JavaBean File Name: beancode.java
Jsp count and java bean - JSP-Servlet
Jsp count and java bean  Please am on a project and i want to create a countdown timer that will have this format HH:MM:SS. Am working with jsp and java beans please somebody help.  Hi Friend, Try the following
JSP bean set property
JSP bean set property   ... you a code that help in describing an example from JSP bean set property... of the bean in which it exists.     <jsp:set Property>
how i connect two page
how i connect two page  strong textlink text

Ads