edit database using jsp and servlet

edit database using jsp and servlet

I am creating a website using jsp and servlets that is used to view houses from a database. I want to be able to edit the information of each house. showAll.jsp shows all the houses and beside that is a link to an edit page. The edit page needs to display all the house information from the database in the textboxes. Please help me to display the information in the textboxes. Below is edit.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Edit Property</title>
    </head>
    <body>
       <h1><img src="images/logo.gif" width="100" height="100" /> LIT Realty <img src="images/logo.gif" width="100" height="100" /></h1>
       <br>
       <form id="editProperty" name="editProperty" method="get" action="EditPropertyServlet">
        <p><em>Please edit any properties details</em></p>
            Enter Street: <input type="text" name="street"  /> 
            <br><br> 
            Enter city: <input type="text" name="city"  /> 
            <br><br> 
            Enter Listing Number: <input type="text" name="listingNum"  /> 
            <br><br> 
            Enter Style Id: <input type="text" name="styleId"  /> 
            <br><br> 
            Enter Type Id: <input type="text" name="typeId"  /> 
            <br><br> 
            Enter number of bedrooms: <input type="text" name="bedrooms"  />

            <br><br> 
            Enter number of bathrooms: <input type="text" name="bathrooms"  /> 
            <br><br> 
            Enter square feet: <input type="text" name="squarefeet"  /> 
            <br><br> 
            Enter description: <input type="text" name="description"  /> 
            <br><br> 
            Enter lot size: <input type="text" name="lotsize"  /> 
            <br><br> 
            Enter garage size: <input type="text" name="garagesize"  /> 
            <br><br> 
            Enter garage Id <input type="text" name="garageId"  /> 
            <br><br> 
            Enter your agent id: <input type="text" name="agentId"  /> 
            <br><br> 
            Select photo: <input type="text" name="photo"  /> 
            <br><br> 
            Enter price: <input type="text" name="price"  /> 
            <br><br> 

            <input type="submit" value="Edit Property" name="editProperty" />
        </form>
    </body> </html>

and edit.servlet:

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException{
            response.setContentType("text/html");
            PrintWriter pw = response.getWriter();
           try
            {
                int id = Integer.parseInt(request.getParameter("id"));
                String street = request.getParameter("street");
                String city = request.getParameter("city"); 
                int listingNum = Integer.parseInt(request.getParameter("listingNum")); 
                int styleId = Integer.parseInt(request.getParameter("styleId"));
                int typeId = Integer.parseInt(request.getParameter("typeId"));
                int bedrooms = Integer.parseInt(request.getParameter("bedrooms"));
                int bathrooms = Integer.parseInt(request.getParameter("bathrooms")); 
                int squarefeet = Integer.parseInt(request.getParameter("squarefeet")); 
                String description = request.getParameter("description");
                String lotsize = request.getParameter("lotsize");
                int garagesize = Integer.parseInt(request.getParameter("garagesize"));
                int garageId = Integer.parseInt(request.getParameter("garageId"));
                int agentId = Integer.parseInt(request.getParameter("agentId"));
                String photo = request.getParameter("photo");
                double price = Double.parseDouble(request.getParameter("price"));

                Connection conn = PropertyDB.doConnection();
                PreparedStatement editpst = conn.prepareStatement("SELECT * from properties WHERE id =" + id); //need to get id from Show.jsp


                editpst.setString(1,street);
                editpst.setString(2,city);
                editpst.setInt(3,listingNum);
                editpst.setInt(4,styleId);
                editpst.setInt(5,typeId);
                editpst.setInt(6,bedrooms);
                editpst.setInt(7,bathrooms);
                editpst.setInt(8,squarefeet);
                editpst.setString(9,description);
                editpst.setString(10,lotsize);
                editpst.setInt(11,garagesize);
                editpst.setInt(12,garageId);
                editpst.setInt(13,agentId);
                editpst.setString(14,photo);
                editpst.setDouble(15,price);

                int i = editpst.executeUpdate();

                if(i!=0)
                {
                    pw.println("<br>Property has been updated");

                }

                else
                {
                    pw.println("Failed to update the data");
                }
            }
            catch (Exception e){
                pw.println(e.getMessage());
            }
      }
 }
View Answers









Related Tutorials/Questions & Answers:
edit database using jsp and servlet
edit database using jsp and servlet  I am creating a website using jsp and servlets that is used to view houses from a database. I want to be able to edit the information of each house. showAll.jsp shows all the houses and beside
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
Advertisements
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database... to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts... example using struts.if anyone knows how to do it..please help me.. thanks a lot
How to edit values in textboxes from database using jsp
How to edit values in textboxes from database using jsp  Hi RoseIndia, I need help to solve my technical problem, i want to edit values in textboxes from database table using jsp, here is my code Please can anyone help me
Upadate Database using updatable fields - JSP-Servlet
Upadate Database using updatable fields  Hi, Thanks for previous answers.They were of Great Help !!! I want to create a jsp in which data is pulled from database and displayed in the updatable fields.Means after user
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your portal but it is not inserting image into database it save in the folder
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 browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I... to use MySQL Database from JSP page. How to retrieve image from database using servlet and display in JSP? Thanks
Retrieve database from the table dynamically in jsp from oracle using servlet
using java servlet from the database in the jsp page...Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few
Upload Excel into Database Table Using SERVLET - JSP-Servlet
Upload Excel into Database Table Using SERVLET  Hi i hava sitution that upload .xls file into database table which has same coloumn names... in database table are NAME,ID,SAL. please help me to upload that excel using
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
Updating Ms Access Database using jsp - JSP-Servlet
Updating Ms Access Database using jsp  Hi I am new to jsp and I am trying to update a record in an access database. I only want to update part of the record because the other columns already have data. When I use Update
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... by using servlet or jsp program by typing the output as like this below... the problem   Get data from database using servlet Retrieve data from
JSP Servlet Search and Edit - JSP-Servlet
JSP Servlet Search and Edit  Hi, I want to thank the people who... to the following jsp. Also, when I use it for a character column, if the backend table...){ alert(id); window.location.replace('http://localhost:8080/examples/jsp
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai, this is my jsp where i have enter multiple username and password and save it to database in single hit user.jsp <form action="UserServlet" method="post
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... in database using JSTL name number Position add
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device">...;/tr> In servlet... try { String strpath
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device">...; In servlet... try { String strpath=request.getParameter("Image
connec to database - JSP-Servlet
connec to database  Need code to connect the application to database. I have developed the application JSP and Servlet
Acees data from database using combo box - JSP-Servlet
Acees data from database using combo box  please let me how i access the data from database when i select combo box combo2 having values Arts... value 11 or 12, otherwise combo box combo2 remain hide. Here is JSP's files
database - JSP-Servlet
database  how to downloaad a file(doc) from database and store in any local system by using servlet
Block edit menu option - JSP-Servlet
Block edit menu option  I am doing a jsp project. I have to control number of characters in a text area upto a limit. How can i block pasting through edit menu and pasting through short cut key [ctrl+v
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
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
jsp page authentication panel using jsp/servlet?
jsp page authentication panel using jsp/servlet?  I have 10 jsp jsp forms and 7 users and i want to grant variour permission like edit,delete and save for users dynamically on forms.So please refer me code
Backup MySQL Database - JSP-Servlet
Backup MySQL Database  Database Sir I have been reading Rose's india tutorial "Using MySQL Database with JSP/Servlet". In the Tutorial you have shown an example of backing up the database. When I tried to backup database
upload to database - JSP-Servlet
to upload a pdf file into database(sqlserver2000) using jsp. In roseindia some examples... into database whenever i want that uploaded pdf file i have to retrieve it from database please help me friends thanks in advance it is very urgent
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp... with the database by writing the program in java. Following is the code: import
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to delete this information in table when click on delete button and save
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?   first registration with email , username, password after >> <> without
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use..., not on another page so use both the jsp pages. http://www.roseindia.net/jsp
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to edit this information in table when clicked on edit button and save
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
How to insert or delete records in MS access database using jsp - JSP-Servlet
How to insert or delete records in MS access database using jsp  Hi friends please provide me a solution that i insert or delete record from a database using java server pages. I used the microsoft access 2003 database. PlZ
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want to work in one page... Pl response.. I do not need getParameter... Pl respose me

Ads