Home Answers Viewqa JSP-Servlet i have 2 jsp page(atm.jsp,delete.jsp) in atm.jsp: i have a table containing values, on click on id value, that number should paste/copy in delete.jsp textbox..

 
 


farooq s
i have 2 jsp page(atm.jsp,delete.jsp) in atm.jsp: i have a table containing values, on click on id value, that number should paste/copy in delete.jsp textbox..
2 Answer(s)      8 months ago
Posted in : JSP-Servlet

hi everyone ..i have 2 jsp page(atm.jsp,delete.jsp) in atm.jsp: i have a table containing values, on click on id value, that number should paste/copy in delete.jsp textbox..

View Answers

August 30, 2012 at 5:46 PM


Here is a jsp application that allow the user to click particular record to delete. As the user clicks the particular button, that record will get displayed into another page and allow the user to delete that record and move back to the main page.

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">

function deleteRecord(id){
    var f=document.form;
    f.method="post";
    f.action='delete.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="delete" value="Delete" style="background-color:red;font-weight:bold;color:white;" onclick="deleteRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

August 30, 2012 at 5:47 PM


continue..

2)delete.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="delete.jsp">
<table border="1">

<%
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);
if(rs.next()){
%>
<tr><td>ID: </td><td><input type="text" name="id" value="<%=rs.getString("id")%>"></td></tr>
<tr><td>Name:</td><td><input type="text" name="name" value="<%=rs.getString("name")%>"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value="<%=rs.getString("address")%>"></td></tr>
<tr><td>Contact:</td><td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="<%=rs.getString("email")%>"></td></tr>

</tr>
<tr>
<td><input type="submit" name="Submit" value="Delete" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>
<%
int id = Integer.parseInt(request.getParameter("id"));
try{
           Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("delete from employee where id="+id+"");
           response.sendRedirect("application.jsp");
}
catch (Exception e){
System.out.println(e);
}
%>









Related Pages:
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
in textbox values in jsp file  Hi am new to java. i need to create... following problem. My Project requirement is as follows: I have a table in batchlogs.mdb... in their issues in the textbox and click the submit button it should search
binding data with textbox on dropdown click
binding data with textbox on dropdown click  Hello friends,Divyesh here. i have jsp page and i would like to bind data with text box on dropdown click. in dropdown employee id are load.and when we select perticular id than how
javascript for textbox - JSP-Servlet
).I need that reason to be displayed one next delete.jsp page so how to get...:",""); window.open('../delete.jsp?id=id&reason='+reason.value,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes'); In delete.jsp If i do
Click on Page Refresh - JSP-Servlet
Click on Page Refresh  hi ,i am working on jsp with mysql. i m facing a problem whenever i click on page refresh or f5 button, the value on form... is click". If u have more problem then give error page code. Thanks
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page
how to set a value of dynamic number of drop down lists on a jsp page and access it value on another jsp page  actually i have to create dynamic...; in this fragment of jsp page i m accessing values of rating1,rating2.... which are names
JSP textbox autopopulation on basis of SQL table values
JSP textbox autopopulation on basis of SQL table values  Hi, I need... CONTROL NEW ABC LEGAL Dept PENDING PQR There are 2 list box on JSP , one... , then a text box (name - 'responsible') on the same JSP should be populated with 'ABC
javascript for textbox - JSP-Servlet
for a textbox ?.I am doing a delet operation.When i clik on a particular record... entering a reason click on ok then record should be deleted so how to write...:8080/examples/jsp/deleteuser.jsp?id='+id,'mywindow','width=500, height=350,toolbar
ID using get the databse latest value and displayed in jsp
ID using get the databse latest value and displayed in jsp   I have... ... after i click the preview button it should show the values you have entered... and displayed in preview.jsp page . so technically pass the new id and display the values
how to display textbox value based on selected option value?
how to display textbox value based on selected option value?  Hi,I have some problem. I use jsp and ajax. first select: 1 second select:2 based on first value I finished above code. ID: xx Name:xx xx is baesd on second
Retaining textBox values in java - Java Beginners
Retaining textBox values in java  Hi all, i have a jsp screen where i have two actions . I have a single textbox and two buttons. My textbox value is becoming null once i click on any one button. I want the textbox value
I have doubt in jsp file.
I have doubt in jsp file.  I have doubt in jsp file. In a jsp file, there should be two buttons. One is start and other is stop. When we click... we click on start button, stop should be enabled and start should be disabled
JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean
JSP - Checkbox remain checked although checked values should depend on values... have different items to choose from. And there is another page final.jsp which... the response.sendRedirect() method. Here are the codes(the jsp codes are too long, so I
how to display jsp page containing mysql query in particular division using ajax ?my code is below bt i cundt get it properly
how to display jsp page containing mysql query in particular division using...="displayFunction()" value="submit" /> </p> </form> <div id="ajaxDiv...(); alert("Please Select Employee Id"); document.getElementById("email").value
retrieving data from database to the textbox depending upon the id in jsp
depending upon another textbox value which is productid.First the id entered by us...retrieving data from database to the textbox depending upon the id in jsp ... the corresponding producttype and product_price should populate into textbox,which a user
get a radio button click value - JSP-Servlet
get a radio button click value  thanks sir for sending code ,but i have one probs that is i m getting a null value i m calling getParameter("id... servlet from another jsp i.e 'main.jsp', then you have to store the value of id
I have to retrieve these data from the field table
the field table. Actually they are separated by comma. I want to take the values as single values like chennai as one value, trichy as one value. and i have...I have to retrieve these data from the field table  Hi. I have
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE  Dear sir, Am having one table called rolemaster. In that there are 2 fields... SystemAdmin 2 Office Bearer Am loading this Rolename into one page called
How to Display values from databse into table
How to Display values from databse into table  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want to display books
retaining textbox values
retaining textbox values  i have a calculator program, when i press a button the value displays but disappears when i press another button so how can i keep values to display when i press multiple buttons
use struts 1.0 to view sql table value on JSP page
use struts 1.0 to view sql table value on JSP page  Here i am using struts 1.0 to view my sql table values on jsp page. But the problem is when i append the value in bean then i find the last row of table is shown repetedly. Any
use struts 1.0 to view sql table value on JSP page
use struts 1.0 to view sql table value on JSP page  Here i am using struts 1.0 to view my sql table values on jsp page. But the problem is when i append the value in bean then i find the last row of table is shown repetedly. Any
Dynamically hide textbox
Dynamically hide textbox  I have a drop down(combo box) with 2 values... the components of file(that is displayed when file is selected) should get hidden dynamically. AVOID PAGE REDIRECTING jsp+servlet+oracle+javascript I am using
How to insert dynamic textbox values into database using Java?
How to insert dynamic textbox values into database using Java?  Hi I am trying to insert dynamic textbox values to database, my jsp form have 2... these dynamic textbox values to database(Oracle 11g)...Please help me out. I have
i have problem in that program - JavaMail
i have problem in that program  1. Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number...++){ int j; for(j=2; j<10; i++) { pw.write(f3+"\n"); f1 = f2
Ajax drop down and textbox
Ajax drop down and textbox  hie frnds I have a dropdown menu in the 3 options(1,2,3) are there if i choose 1 then I should get 1 text box if i select 2 the 2 textboxes should come can any one help me in this problem Thanx
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
dynamic generation of html:select tag from textbox value
give some input in a textbox and click on a add link. It should be added... action class? And i have no idea how to implement this. I am using jsp. Any help...dynamic generation of html:select tag from textbox value  Hi, I am
i need the source code to generate id in jsp
+1,like automatically when i click the button...as well i have several kinds of generate ids each should have some range...plz give the source code in jsp with ms...i need the source code to generate id in jsp  hai,i need the source
how to display values from database into table using jsp
how to display values from database into table using jsp  I want... to display that? For example i have some number of books in database but i want to display books based on either bookname or authorname, for this i created one jsp page
Form Should not load
Form Should not load  I have a jsp page which has textbox and dropdown box, when I submit it, the page reloads and the textbox and dropdown box also reload which should not happen. I need to retain the value of text and dropdown
ID using get the databse latest value and displayed in jsp
; <% } } catch(Exception e){} %> I have done jsp page like this .... I... etc,... How to get latest values in my jsp page and id will be shown in url...ID using get the databse latest value and displayed in jsp  function
How to Autogenerate of ID from database and show on JSP page?
increasin 1 in the previously stored tsk id) on JSP page when I click...How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
How to Autogenerate of ID from database and show on JSP page?
increasin 1 in the previously stored tsk id) on JSP page when I click...How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
How to Autogenerate of ID from database and show on JSP page?
increasin 1 in the previously stored tsk id) on JSP page when I click...How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers on JSP
Formatting a Message Containing a Number
Formatting a Message Containing a Number In this section, you will learn how to format a message containing a number. You can also format the message that contains a number. The class MessageFormat provides advanced message formatting
Struts 2 issue
Struts 2 issue  hi, I have one jsp page and having one hidden... am redirecting request to same jsp page and on click of submit submiting values... getting value (show,show) so how we can overite data i want variable should
Session ID
Session ID  How can I change the session ID of the page?   ... or with people acquiring other users' data. The session ID value should be managed... to a particular page. Generally, you should not attempt to change users
How to hide and show some field on a radio button click
and cheque number label and textbox to be invisible when by cash radio button is clicked.and they should be visible when by cheque radio button is clicked. I have...; <jsp:include page="calendar_1.html" /> </td>
how to get the values from dynamically generated textbox in java?
as per the retrieved data) and I want to store textbox values into the two table...how to get the values from dynamically generated textbox in java?  I have retrieved data from two table both table contains two column and I display
How to show data from database in textbox in jsp
of autocompletebox in JSP. As the user tpe any letter in the textbox, corresponding values...How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve
[JSP] How to pass back ID to previous page.
[JSP] How to pass back ID to previous page.  Hi experts, May I ask... page is selected from database where IDPRODUCT=". I don't know how to pass back the IDPRODUCT. Suppose I have ViewProducts.jsp and ViewPhotosOfProduct.jsp.
Autocomplete textbox with database in jsp and follow the MVC model
Autocomplete textbox with database in jsp and follow the MVC model  i have one problem in my project i try to generate the autocomplete textbox...'> </div> </body> </html> 2)get.jsp: <%@page
How to get an Id vaue - JSP-Servlet
or delete etc button i have to go that page and i want that selected id value...("./jsp/delete1.jsp"); then it sis going to that jsp where i need a id values... a act value.When this page is submitted it is going to servlet their i am getting
populating textbox value from the database using onchange function,
;hi, Everyone I have a problem regarding poulatinng the value in textbox after selecting from dropdownlist. i have a form in jsp n I created the dropdown list... is when i select the value the page is refreshed and all the value entered is lost
MySQL Generate AlphaNumberic Id In JSP
will create a JSP page for generating the employee number and the bill number...MySQL Generate AlphaNumberic Id In JSP In this section we will discus about how to generate id in specific format in MySQL and JSP. This example explains
dynamic generation of html:select tag from textbox value
dynamic generation of html:select tag from textbox value  Hi, I am a newbie to java and struts. In my application, I have a requirement like when i give some input in a textbox and click on a add link. It should be added
when radio button is selected corresponding jsp page should open
when radio button is selected corresponding jsp page should open  how to write code in HTML & jsp, when we click on radio buttons the corresponding jsp page should open..!   <html> <script> function
When i click on Monitor Tomcat, it shows
When i click on Monitor Tomcat, it shows   To run servlet i have seen.../introductiontoconfigrationservlet.shtml Hello i followed each and every step same to same as given, i have installed java 7 and tomcat 7, when i click on Monitor Tomcat it shows
When i click on Monitor Tomcat, it shows
When i click on Monitor Tomcat, it shows   To run servlet i have seen.../introductiontoconfigrationservlet.shtml Hello i followed each and every step same to same as given, i have installed java 7 and tomcat 7, when i click on Monitor Tomcat it shows

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.