jsp _how to edit table of data displayed using jsp when clicked on edit button

8

Upload: rithuik1598

Post on 28-Oct-2015

1.040 views

Category:

Documents


1 download

DESCRIPTION

vuyyy

TRANSCRIPT

Page 1: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 1/8

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

Home Java Frameworks Database Technology Web Development Build/Test Tools Servers PHP

Home Answers Viewqa JSP-Interview-Questions jsp :how to edit table of data displayed using jsp when clicked on edit button Login

Ask Questions?Question

shruthi

jsp :how to edit table of data displayed using jsp when clicked on edit button

4 Answer(s) a year and 3 months ago

Posted in : JSP-Interview Questions

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 the data when clicked on save button.. how can i do this

Advertisement

Follow us on Twitter, or

add us on Facebook or

Google Plus to keep you

updated with the recenttrends of Java and otheropen source platforms.

691

Follow

Have Programming

Question? Ask it here!

May 15, 2012 at 2:13 PM

View Answers

The given code retrieve data from database and display in the html table. At each row, there is a buttonwhich 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";

Search

Latest Frameworks Category

jav a based question

Struts2 and Hibernate

i want to create an application with only a button which onclick displays table from database using struts2 and hibernateon eclipse

array of string

Scanner

project

Spring framework

Struts2 and Hibernate

Struts2 and Hibernate

jsp code

Page 2: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 2/8

May 15, 2012 at 2:14 PM

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

</tr>

<%

}

%>

<%

}catch(Exception e){

e.printStackTrace();

}

%>

</table>

</form>

</body>

</html>

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");

Page 3: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 3/8

May 15, 2012 at 6:49 PM

August 23, 2012 at 11:21 AM

Post Answer

Related Pages:

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 jspprogram which displays data in the form of table ..now i... the data when clicked on save button..

how can i do

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... want to edit this

information in table when clicked on edit button and save the data when clicked on save

button.. how can i do this The given

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);

}%>

My database is xml..How can i do the same thing when database is xml..

Application is working fine ...

but the movement i click on edit button its not displaying any values .. wat might be the prob .. ?

reply soon

Post Answer

Preview:

► JDBC API

► Download Java Script

► Java

► Java

► JSP

► Edit XML

► JavaScript

► Core Java Tutorial

► Edit Editing

Page 4: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 4/8

Update / Edit data

field that i have prepared under the submit button. btw, im using jsp. thank you... consists of that

particular id. When the user clicks the particular edit button... user data in the data base. the thing

is, when i click on submit reference

Advertisement

Edit the record.

Edit the record. sir, I have a table consist of huge data.I have displayed that data.side of them there

is an edit button which will edit that particular record.after editing the data i want to edit another rowwhich is next

Drop down and radio button value on edit action

Drop down and radio button value on edit action HI, I have... the value from dropdown and radio

button.. But the problem goes with edit action.. While the edit form is being displayed it gets all thevalues from the database

extract data fom table when a button is clicked in front end page using mysql5.0 and tomcat6.0

extract data fom table when a button is clicked in front end page using mysql5.0 and tomcat6.0

sir, i want to extract data from table which is stored in mysql5.0 databse, when a button is clickedin front end page using

uitableview edit done button

call, when Edit / done Button is clicked. In that case you need not to write...uitableview edit done

button How to add Edit / Done button in UITableView with an action on click? UITableview Editdone Button To add

edit data

edit data sir i want to do edit a particular customers information after he logs in, i am also usingsessions. thank you

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not

Page 5: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 5/8

working, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not

working, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were not

working, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

delete and edit options in struts

delete and edit options in struts Hi, I am doing an web application using struts, jsp, tomcat server,

oracle as a database in netbeans IDE 7.1.2, I... errors but the edit and delete operations were notworking, so please modify my

insert , edit , and delete button in one jsp page

insert , edit , and delete button in one jsp page hello I want to ask about the way of creating a jsppage contains insert , edit , and delete buttons and manipulate data in database directly. any helpplease or hints

radio button value on edit action

radio button value on edit action This is my edit.jsp code...In my......Problem 'm facing is on editaction 'm not retrieving radio button value..i have...="cancel" class="button" onclick="return

f2(edit_customer)"> <

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

Edit Distance

Edit Distance I want java programming ask from user input two string and the program find the editdistance between two strings and find table and optimal solution using GUI

Add Edit And Delete Employee Information

Add Edit and Delete Employee Information Using Swing ..., edit and delete the Employee's

information from the database using java swing... enters the id and click the edit button, the

information of the particular

get a value when a radio button clicked - JSP-Servlet

get a value when a radio button clicked sorry sir my actual probs is that 1st i m callig a jsp in that i m

displaying a table where i used a radio button to access a value(also used u r code),then in this jsp i

Page 6: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 6/8

m having a forms

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

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

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 codePlease can anyone help me

JSP Servlet Search and Edit - JSP-Servlet

to the following jsp. Also, when I use it for a character column, if the backend table...JSP Servlet

Search and Edit Hi, I want to thank the people who... Post). The code works fine when I'veincorporated it in my web application, its

sorting and filtering the displayed table data using jsp and xml

sorting and filtering the displayed table data using jsp and xml I have created a xml file and a jspfile, which uses DOM parser to display... that is displayed in web page. How to do it ??? Please help

as soon as possible

UINavigationBar Edit Button

UINavigationBar Edit Button UINavigationBar Edit Button Given is the code that adds a edit buttonitem as a nav bar item in your UINavigation Controller. -(void)viewDidLoad; { [super viewDidLoad];UINavigationBar* navBar

data grid with edit and delete options at each row.

data grid with edit and delete options at each row. i want to display the table data in the format of

data grid with edit and delete options at each row. i need it very urgently. advance thanks

Displaying image when clicked on URL in jsp - JSP-Servlet

Displaying image when clicked on URL in jsp Hi, I am using... For Screenshot : abc.jpg here

abc.jpg is a url and when clicked would show me an image... *.jpg images displayed depending

upon the page url clicked. Please guide me

Delete and add row from Table View iPhone

to delete and also how to add row into the table view iPhone, with the help of edit button on

navigation bar. When we press Edit button it will show you ADD... the variable for the table and the

action for the Edit button which is present

JSP - Update displayed content & session variables when user clicks on a button - JSP-Servlet

JSP - Update displayed content & session variables when user clicks... on certain buttons (say an

img of a "+" sign). When the user does that, I would like JSP to do some internal check and thenincrement the value of a number

Dojo Inline Edit Box

Dojo Inline Edit Box In this section, you will learn how to edit any data... the role as a <div> tag

when not in edit mode. When you click widget text

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

get a value when a radio button clicked - JSP-Servlet

get a value when a radio button clicked Here is my code sir please help me if any changes in the

code please give me sir thanks in advance...; //System.out.println("******* id in jsp login Is ******" +id);f.submit

Page 7: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 7/8

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

Non-edit Combobox with auto fill - Swing AWT

Non-edit Combobox with auto fill Hi, I have a non-edit... typed by the user. For example, ["Callisto",

"Charls", "chim"] are the data in JCombobox model. When user type 'C', JCombobox selects "Callisto

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

data update sir, I have a table consist of huge data.I have displayed that data in table format be

side of a table an edit button which will edit... the data and edit it based on

subjectcode(varchar)this should be done using jsp

data update

displayed that data in table format be side of a table an edit button which will edit... the data and

edit it based on subjectcode(varchar)this should be done using jsp... edit/update data and saved

them into that table again

How to save image after edit in php

How to save image after edit in php Hello, I have create a simple... successfully but i don't know howto replace orignal image with the effects. please...;body> <form name="form1" action="index.php"

enctype="multipart/form-data

Login Box appears when a button on the webpage is clicked

Login Box appears when a button on the webpage is clicked How to create a Login Box on a web

page that appears only when a button that is already present on the page is clicked

JSF Development

Software SolutionsWeb Designing

Website Development Web PromotionServices Content Development

Content DevelopmentASP.NET Hosting

Web Hosting ServicesCRM

E-Commerce Solutions

Services

Page 8: Jsp _how to Edit Table of Data Displayed Using Jsp When Clicked on Edit Button

8/27/13 jsp :how to edit table of data displayed using jsp when clicked on edit button

www.roseindia.net/answers/viewqa/JSP-Interview-Questions/25903-jsp-how-to-edit-table-of-data-displayed-using-jsp-when-clicked-on-edit-button.html 8/8

Outsourcing

ERP

M-Commerce

Flex Development

Web Redesigning

Web Development

Logo Design

Web Design Packages

Domain Registration

SEO Services

Search Eng. Optimization

Search Eng. Submission

SEO Tips

SEO Portfolio

Web Promotion Plans

Article Writing

Blog Writing

New s Writing

SEO Copyw riting

Technical Documentation

Article Marketing

Unix Hosting

E-Commerce Hosting

Window s Hosting

Hosting Plan

Home Privacy Policy© All Rights are Reserved for Rose India