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



Home Answers Viewqa JSP-Servlet Updating user profile

Have Programming Question? Ask it here!
 
 
 


praneeth
Updating user profile
2 Answer(s)      a year and 10 months ago
Posted in : JSP-Servlet


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


Advertisement
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
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
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
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 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
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  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
update profile
update profile  coding for update profile
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
Editing the Profile
Editing the Profile  how to populate drop-down menu instead of text box in editing the profile
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
coding for update profile
coding for update profile  coding for update profile
updating & deleting an employee
updating & deleting an employee  can anyone help out me please? advance thanks warm regards
Updating log4j programatically
Updating log4j programatically  Is there a ready made utility which I can use to edit the log4j.xml programmatically
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
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
profile doesn't match application identifier
profile doesn't match application identifier  profile doesn't match application identifier
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
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
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
Uploading a Profile with image[file] into a sql database
Uploading a Profile with image[file] into a sql database  I need to upload a file along with the some text into a database ......[ Similar to http://www.roseindia.net/jsp/jspfileupload/employeeuploadprofile_image.shtml
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
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
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
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
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
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
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
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 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 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
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
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 Selects
user validation
user validation  i hv just started with my lessons in jsp n also doin...(); } } /* if(userName.equals(request.getParameter("user")) &amp;&...;tr><td>Username:</td><td><input type="text" name="user">
Simple Bank Application in JSP
application in jsp . In this application user can Update the User Profile, Cash...: Create a Home Page ("index.jsp") to Login and New User Registration... a web page ("saveuser.jsp")  to Register the new user.  
profile doesn't match any valid certificate private key pair in the default keychain
profile doesn't match any valid certificate private key pair in the default keychain   Hi, I am not able to create my application build. Following error is coming profile doesn't match any valid certificate private key pair
Updating rows who has same id with different values for each row from java program
Updating rows who has same id with different values for each row from java program  Here is my requirement, Following is a table which contains 5 rows with same id. student table: sid sname age 2 aruna 25 2
verfication of user login and then redirecting it to user defined page
verfication of user login and then redirecting it to user defined page ...() to redirect to a user defined page..but..wen i press the submit button,the html page calls teh servlet..but..the servlet.is not redirecting to a user defined
Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating in a CMP bean.
Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating... for relationship assignment and relationship updating in a CMP bean. The assignment
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
user log in according to their role
user log in according to their role  i want a jsp code for different users log in to different pages according to their role.example normal user and administrator. normal user for user page and administrator for admin page
JSP User-Agent
JSP User-Agent          JSP User-Agent is used to display the user-agent. The page displayed you the name of the client requested the page
escaping user input in php
escaping user input in php  Is it possible to escape the user input while submitting data into database in PHP
 

 

 

DMCA.com