Home Answers Viewqa JSP-Servlet How to connect to dao n bean classes with jsp

 
 


shraddha srivastava
How to connect to dao n bean classes with jsp
0 Answer(s)      a year and 7 months ago
Posted in : JSP-Servlet

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 Pages:
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
CRUD DAO
CRUD DAO  how to create dao for create,read,update and delete?  ... register(StudentBean bean) { /** * method to search student..."); try { // connect to DataBase // connect to DataBase
DAO Classes
DAO Classes  login page code for Dao classes
dao
(); } return conn; } } //bean: package
Bean
value whit useBean classes org.apache.jasper.JasperException: /proces1.jsp(7,0) The value for the useBean class attribute ../public_html/WEB-INF/classes... visit the following links: http://www.roseindia.net/jsp/simple-jsp-example
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
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
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
implementing DAO - Struts
writing DAO Implementation classes." This is her advice. But as a beginner who just... This tutorial shows, how to create the source code of Dao and DaoImpl class..., exam in 3 days, and just now i found out our lecturer post a demo on DAO
java struts DAO - Struts
java struts DAO  hai friends i have some doubt regarding the how to connect strutsDAO and action dispatch class please provide some example to explain this connectivity. THANKS IN ADVANCE
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 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
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
DAO - JDBC
DAO  what is dao ? and how to use it?  Hi Friend, The DAO is a pattern that provides a technique for separating object persistence and data access logic from any particular persistence mechanism or API. Thanks
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
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....   <jsp:useBean id=?bean name? class=?bean class?  scope
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
Connect JSP with mysql
; This query creates database 'usermaster' in Mysql. Connect JSP with mysql : Now in the following jsp code, you will see how to connect... Connect JSP with mysql   
An Entity Bean Example
creates instances of the session bean based on the implementation classes..., such as relational database an entity bean persists across multiple session and can be accessed by multiple clients. An entity bean acts as an intermediary between a client
Bean
Bean  what is bean? how to use bean   HTML Code: Contents MOBILE STORE HOME PRODUCTS IMAGES COMPANY BRANCHES DEALERS FEEDBACK       Username       Password
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
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
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
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
spring DAO module turorial
spring DAO module turorial  how to integrate springDAO and spring webMVC
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
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
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
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 <
Connect JSP with mysql
you how to connect to MySQL database from your JSP code. First, you need to create database and then write jsp code to connect jsp to database. 1. Create... Connect JSP with mysql   
Understanding Spring Struts Hibernate DAO Layer
Understanding Spring Struts Hibernate DAO Layer... how Spring Hibernate and Struts will work together to provide best solution... Hibernate DAO Layer   The Data Access Object for this application is written
servlet n jsps - Java Beginners
servlet n jsps  How to do: 1.After log-out, if user cilick on "back" button he shouldn't able see the previous page. 2.I want to expire the page...://www.roseindia.net/jsp/ Thanks.   hello, 1 = you can disable
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: <
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: http://www.roseindia.net/jsf/myfacesspring/loginRegistration.shtml Hope
Send Mail Bean
Send Mail Bean     In our application we have developed mailer bean that sends welcome email when a new user is registered to the system. Mail Bean also used when user
Connect to the database
Connect to the database  how to connect to the database in the iphone
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
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used... bean with a jsp. Here is an example which explains the purpose.     Code
how to connect swings with jdbc... - Java Beginners
how to connect swings with jdbc...  Hi friends, Is it possible, to connect swings with data base like oracle....i want to store data into database... by using servlets and jsp but is it possible by using swings........ for data base
how to connect webcam in html
how to connect webcam in html  how to connect webcam in html.emphasized text
Stateless Session Bean Example
the compiled classes into an enterprise bean JAR. II. Creating the calculator Web.... Finally, a JSP scriptlet invokes the enterprise bean?s business methods, and JSP... Stateless Session Bean Example   
Java Bean - Java Beginners
Java Bean  Sir, How can i add a java bean into a target GUI.... Thanking you Pabitra Kr Debanth.   Hi friend, Java Bean classes must..., it will be a visible Java Bean. Java Beans may also be invisible
how to code-updating some details n some details r unchanged
how to code-updating some details n some details r unchanged  i have... is-if the user want to change only contact n he want to get the remaining details unchanged,then how to do that..... i know how to update,but how to get the old