Updating user profile

Updating user profile

how should i provide user to update his profile with edit option including entered data by user should be shown in jsp page fileds

View Answers

October 3, 2012 at 12:25 PM

The given code retrieve data from database and display in the html table. At each row, there is a button which consists of that particular id. When the user clicks the particular edit button, that data will get shown in another page and allow the user to update the record.

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

October 3, 2012 at 12:25 PM

continue..

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>









Related Tutorials/Questions & Answers:
Updating user profile
Updating user profile  how should i provide user to update his profile with edit option including entered data by user should be shown in jsp page.... When the user clicks the particular edit button, that data will get shown
coding for updating profile
coding for updating profile  coding for updating profile
Advertisements
user profile - JSP-Servlet
user profile  how to create a user profile for each user in the database and enable the user to modify it using jsp
ModuleNotFoundError: No module named 'user_profile'
ModuleNotFoundError: No module named 'user_profile'  Hi, My Python... 'user_profile' How to remove the ModuleNotFoundError: No module named 'user_profile' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'user_profile'
ModuleNotFoundError: No module named 'user_profile'  Hi, My Python... 'user_profile' How to remove the ModuleNotFoundError: No module named 'user_profile' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-spirit-user-profile'
ModuleNotFoundError: No module named 'django-spirit-user-profile'  Hi...: No module named 'django-spirit-user-profile' How to remove the ModuleNotFoundError: No module named 'django-spirit-user-profile' error? Thanks
ModuleNotFoundError: No module named 'django-user-profile'
ModuleNotFoundError: No module named 'django-user-profile'  Hi, My... named 'django-user-profile' How to remove the ModuleNotFoundError: No module named 'django-user-profile' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-user-profile'
ModuleNotFoundError: No module named 'django-user-profile'  Hi, My... named 'django-user-profile' How to remove the ModuleNotFoundError: No module named 'django-user-profile' error? Thanks   Hi
Maven Repository/Dependency: org.nuxeo.ecm.platform | nuxeo-user-profile
Maven Repository/Dependency of Group ID org.nuxeo.ecm.platform and Artifact ID nuxeo-user-profile. Latest version of org.nuxeo.ecm.platform:nuxeo-user-profile dependencies. # Version Release Date
ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile'
ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile' ...: ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile' How to remove... to install padas library. You can install odoo12-addon-base-user-role-profile
ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile-example'
ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile...: ModuleNotFoundError: No module named 'odoo12-addon-base-user-role-profile-example...-user-role-profile-example' error? Thanks   Hi, In your
Update Profile
; The Update Profile page allows the logged in user to update his/her profile... or change his/her profile in the registration form, user has to click on the "... from database and displayed on the Updating Form. User can update the require
Updating log4j programatically
Updating log4j programatically  Is there a ready made utility which I can use to edit the log4j.xml programmatically
updating & deleting an employee
updating & deleting an employee  can anyone help out me please? advance thanks warm regards
profile display
profile display  Is it possible to create a user profile in Servlet and JSP   Please visit the following links: http://www.roseindia.net/servlets/web-application.shtml http://www.roseindia.net/jsp/user-registration
profile display
profile display  How to create a user profile in JSP   Please visit the following links: http://www.roseindia.net/servlets/web-application.shtml http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
profile display
profile display  Create Jobseeker's profile in JSP and Servlet   Please visit the following links: http://www.roseindia.net/servlets/web-application.shtml http://www.roseindia.net/jsp/user-registration-form-using
updating a table in a database - SQL
updating a table in a database  give me complete source code in java to execute the sqlquery such that (update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
Updating using AngularJS
Updating using AngularJS  Shopping.html <!DOCTYPE HTML PUBLIC... one more button for updating items in the table for Updating Items in Shopping.html. On clicking updating button for each row ( as like Remove button in each
profile display
profile display  how to display matching jobs in jobseeker's profile using jsp-servlets?   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user
profile page
profile page  sir, i am beginer in php i am creating simple web site.i am creating login form.the user login he can any status,photo update.he can display in home pages in all user login.but problem in user goto profile page
profile display
profile display  Search page to display matching results in JSP and Servlet   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user-search.shtml
Update Profile
Update Profile       Update Profile This facility is used for updating user... user wishes to change their information, he may proceed by clicking on Update
Updating multiple value depending on checkboxes
Updating multiple value depending on checkboxes  Hi .. I want to Update the multiple values of database using checkboxes and want to set the session for selected checkboxes..? please answer if any one knows as soon as possible
profile display
profile display  how to display matching Results using jsp-servlet?   Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user-search.shtml http
profile display
profile display  Fetch Matching jobs in JSP Servlet  Please visit the following links: http://www.roseindia.net/servlets/search.shtml http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp
Updating from MySQL 5.0 to 5.5 cPanel
Updating from MySQL 5.0 to 5.5 cPanel   Updating from MySQL 5.0 to 5.5 cPanel
Problem in updating query in Hibernate - Hibernate
Problem in updating query in Hibernate  Hi, I have used a query to update the existing columns of one table. The query updates the records in the main table but it does not update the tables that are mapped from the main table
update profile
update profile  coding for update profile
how to code-updating some details n some details r unchanged
how to code-updating some details n some details r unchanged  i have... : bloodgroup : my requirement is to update the details of user. and i had written the update query,but with that query all the details are updating... my doubt
Editing the Profile
Editing the Profile  how to populate drop-down menu instead of text box in editing the profile
updating an access database with visual basic 2010
updating an access database with visual basic 2010  I am building a program in visual basic 2010 that connects to an access database. I was wondering if you could help me figure out the code for the save button. When
updating column automatically based on system date
updating column automatically based on system date  hi, can any one give solution for my question i have a table called leave balanced(leave-id,leave balance,etc are column),in leave balance column each employee has some leave
Ios Swift developer for updating current app
Ios Swift developer for updating current app  Hi, I have previously developed iOS application in Swift programming language. This application is developed in Swift and some of the Objective C libraries. Developer must know
Lock while inserting/updating database in multithreaded.
Lock while inserting/updating database in multithreaded.  Hi, I am having a multithreaded process which replicates the data from many table to one... inserting/updating to database. I dont know what is the issue but it was never
profile display
profile display  JSP Servlet Search Page   1)search.jsp: <html> <head> </head> <body> <br><br><... also visit the following links: http://www.roseindia.net/jsp/user-search.shtml
what is wrong with my JSP codes for updating a form?
what is wrong with my JSP codes for updating a form?  Hi experts, I have tried to emulate a code from a textbook but it doesn't work in my program. Hope someone can advise me where I had gone wrong. Tks. I've set up my
Starting MySQL.The server quit without updating PID file
Starting MySQL.The server quit without updating PID file  Starting MySQL.The server quit without updating PID file (/var/lib/mysql/xxxxxx.pid
coding for update profile
coding for update profile  coding for update profile
ModuleNotFoundError: No module named 'profile_it'
ModuleNotFoundError: No module named 'profile_it'  Hi, My Python... 'profile_it' How to remove the ModuleNotFoundError: No module named 'profile_it' error? Thanks   Hi, In your python environment you
Starting MySQL....The server quit without updating PID file
Starting MySQL....The server quit without updating PID file  Hi, My... error: Starting MySQL....The server quit without updating PID file (/var/lib/mysql/xxxxx.pid). MySQL Restart fails and the server quit without updating PID
Starting MySQL.. ERROR! The server quit without updating PID file
Starting MySQL.. ERROR! The server quit without updating PID file  I...: Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib... updating PID file" was coming because there was no space on Hard disk. Thanks
profile doesn't match application identifier
profile doesn't match application identifier  profile doesn't match application identifier
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
Updating variables in a loop? and only printing certain messages after the first iteration?!
Updating variables in a loop? and only printing certain messages after the first iteration?!  I've written a program that reads two values. I then want it to repeatedly read a further two values until someone enters 0
user in mysql
user in mysql  how to create user in mysql?   Please visit the following link: http://www.roseindia.net/mysql/mysql5/mysql-creating-account.shtml (adsbygoogle = window.adsbygoogle || []).push
updating rows which contains same id, different value for each row
updating rows which contains same id, different value for each row  Student table: sid name age 3 suresh 24 2 surya
user registration
user registration  hi frnds...am working on a project in JSP.i want to create a user registration form with username,password,mail id and check box option for community selection.once the details are registered i want to save
Version of com.scalaone>xsbt-profile dependency
List of Version of com.scalaone>xsbt-profile dependency
User Module
User Module The user first need to make registration on the website for appearing in the online examination. After the making successful registration he.... User does the following task Login to the application ADS_TO_REPLACE_1

Ads