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



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..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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)      2 years and 3 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..


Advertisement
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 Tutorials/Questions & Answers:
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
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
Advertisements
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
I have posted a number of question but no one has answered?
I have posted a number of question but no one has answered?  No one has responded for ten days now. However my first question was answered on the same day. Is there a limit to the number of questions you can ask or am I doing
change database values when click next button on jsp page
change database values when click next button on jsp page  How to retrive database values rondomly and display jsp page ,when user click next and previous bottons change the values on jsp page
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out  how to highlight the field in image,when i have entered into that corresponding field's textbox. Here webpage
i have developed the application in jsp(front-end -jsp,business logic-jsp).it is very slow when accessing the page - JSP-Servlet
i have developed the application in jsp(front-end -jsp,business logic-jsp).it is very slow when accessing the page  i have developed the application in jsp only.i did not use any classes.application is very slow when access
i have one txt field and one button.when i entere any test in testfield then only button should be enabled.
i have one txt field and one button.when i entere any test in testfield then only button should be enabled.  i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need
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
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
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this   i have one txt field and one button.when i entere any test in testfield then only button should
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
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
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
i have problem with classnofounderror
i have problem with classnofounderror   import java.sql.*; public class Tyagi { public static void main (String args[])throws SQLException { ResultSet rs; try { Class.forName
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
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.  I have a tex box. in that i want user should enter data in the format specified(for eg--abcde_)how
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 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
I have problem in my Project
I have problem in my Project  Dear Sir, i have problem in my project about Jtable i have EDIT JButton whenevery i was click on edit he is display all data from database but i want to select any row
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
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
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
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
i have an ques. of advanced java
i have an ques. of advanced java  write a wap to implement AWT by login form
i have a problem in spring - Spring
i have a problem in spring  spring Aop: how to configure proxyfactorybean in xml file for providing advices for one particular class
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
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
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
have no idea of doing it..... - JSP-Servlet
have no idea of doing it.....  how to create an jsp program to simulate rolling of a pair of dice. when a number is clicked the dice should roll and display the corresponding number present
Advertisements
 

 

 

DMCA.com