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



Home Answers Viewqa JSP-Servlet edit database using jsp and servlet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Karen Wilson
edit database using jsp and servlet
0 Answer(s)      11 months ago
Posted in : JSP-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());
            }
      }
 }

Advertisement
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
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
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
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
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
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
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
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
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
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
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
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: http://www.roseindia.net/jsf/myfacesspring/loginRegistration.shtml Hope
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
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
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
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
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
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
connec to database - JSP-Servlet
connec to database  Need code to connect the application to database. I have developed the application JSP and Servlet
database - JSP-Servlet
database  how to downloaad a file(doc) from database and store in any local system by using 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
in order to create jsp and servlet code to add,delete,edit,list of persons in eclipsejavaee
in order to create jsp and servlet code to add,delete,edit,list of persons in eclipsejavaee  in order to create jsp and servlet code what all files we need to create in eclipse --dynamic web project
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
Advertisements
 

 

 

DMCA.com