Home Answers Viewqa Java-Beginners Java servlet with jsp on sql server

 
 


Ramkumar P
Java servlet with jsp on sql server
1 Answer(s)      7 months ago
Posted in : Java Beginners

How to delete a user by an admin with check box in Java Servlet with jsp on Sql Server?

View Answers

October 3, 2012 at 3:55 PM


Here is a jsp example that can delete the multiple record from the database by selecting checkbox.In the given code, we have specified only three fields bookid,author and title in the database.

1) Create book.jsp

<%@page import="java.sql.*"%>

<form name=myname method=post action="delete.jsp">
<table border="1">
<tr><td></td>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; while(rs.next()){ %>
<tr><td><input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>></td>
<td><%= rs.getString("bookid") %></td>
<td><%= rs.getString("author") %></td>
<td><%= rs.getString("title") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="submit">
</form>

2) Create delete.jsp

<%@page import="java.sql.*"%>

<%String id[]= new String[10];
for(int i=0;i<10;i++){
id[i]=request.getParameter("check"+i);
out.println(id[i]);
}
%>
<%try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
st.executeUpdate("delete from book where bookid='"+id[a]+"'");

}
}catch(SQLException e){ 
    System.out.println(e.getMessage()); 
    }
    %>









Related Pages:
Java servlet with jsp on sql server
Java servlet with jsp on sql server  How to delete a user by an admin with check box in Java Servlet with jsp on Sql Server?   Here is a jsp example that can delete the multiple record from the database by selecting
java and sql server NOT Mysql - JSP-Servlet
java and sql server NOT Mysql  Hi guys. Thank you all... was not properly answered. What I wanted was JSP CODE that can insert and retrieve image from MS SQL server NOT MySQL. Or is it not possible to do it in MS SQL server
java,sql - JSP-Servlet
java,sql  Hi Amardeep, Thank you from the bottom of my.... For read more information: http://www.roseindia.net/jsp/ Thanks.  ... any appreciable result. Unfortunately, my java coding skills are not as sharp
java sql - JSP-Servlet
java sql  I need to diplay only 10 records per page from my resultset. while(rs.next())loops through entire rs. How can I use a for loop... for more information. http://www.roseindia.net/jsp/ Thanks
SQL Query - JSP-Servlet
: Syntax error or access violation message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version...SQL Query   AS mysql backend updation query shows a syntax error
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program
server - JSP-Servlet
server - set the environment variable  How to set the environment variable in Java Servlet  Hi,To set the environment variables right click on the My Computer->properties- >advance->Environment Variables->
java server programming : servlet - JSP-Servlet
java server programming : servlet  hi all, can you help check what's wrong with my servlet that i have a null pointer exception.Thanks ERROR... servlet request * @param response servlet response */ protected
jsp sql server 2005 connectivity
jsp sql server 2005 connectivity  your jsp mysql tutorial is very help full.Please tell me how to connect jsp with SQL server 2005
server side scripting java - JSP-Servlet
server side scripting java  I Very new to java server pages I am doing a project in java messaging service so in that i have a client on d server... on the server side i want that in the client side as pop up window
mysql server connectivity - Java Server Faces Questions
mysql server connectivity  hello friends, my question is that i m not able to connect jsp, servlet with sql 2000. i know we have to do some changes in administrative tools in control pannel but after click
jsp -sql - JSP-Servlet
jsp -sql  Hello Sir/Madam, Please send me the error in the following sql code if any. I did not get any error message and iam not getting...://www.roseindia.net/jsp/bank.shtml Thanks
server-jsp - JSP-Servlet
server-jsp  how can we implement a simple database(ms access) for storing information about the HTTP requests sent to a web server(database
How to add value from sql server in dropdownlist
How to add value from sql server in dropdownlist  I have created a hospital management project using jsp servlet, where one form name is patient registration, in that form i have taken id, name, and i want to retrieve a patient
Introduction to the JSP Java Server Pages
. Introduction to JSP Java Server Pages or JSP for short is Sun's...; JSP Tutorials - Introducing Java Server Pages Technology... JSP termed as Java Server Pages is a technology introduced by Sun
date problem in sql server - SQL
date problem in sql server  select count(*) from xxxx_tbl where emplid="+emplid+" and work_dt=#"+work_date+"#"; work_date is in string ,Backend is sql server 2000.i am getting the date problem when using in jsp page.  
JDBC Connection code to connect servlet with SQL Server 2008
JDBC Connection code to connect servlet with SQL Server 2008  Please ans me why it is not connect i use netbeans IDE7.0 Jdk 1.7 i also add sqljdbc4.jar but the output is SEVERE: Java Runtime Environment (JRE) version 1.6
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void bookedButton() { try { Class.forName... with sql server connectivity at the background to save the data. Now, after
Java Servlet - JSP-Servlet
Java Servlet   Hello Sir Could you help me in understanding directory Structure for servlet page in eclipse (IDE). I save my Sevlet in WEB-INF but it is not displaying, it is displaying code of servlet. Process used
java servlet - JSP-Servlet
, Put servlet-api.jar into the lib folder of apache tomcat server. Thanks...java servlet  hi friends, Thanks in advance. Am poornima am created new servlet in eclipse its open but without including any code am getting
Java compilation error - JSP-Servlet
are stored in database(sql), the file attachment also will be kept in the server...\Sema\org\apache\jsp\employee_005fupload_005fprofile_005fimage_jsp.java:9: package...\apache\jsp\employee_005fupload_005fprofile_005fimage_jsp.java:11: package
sql exception - JSP-Servlet
sql exception  Dear sir , I am working in a web-based project, In my system it is working fine but at client side getting the following exception so how to resolve this help me... java.sql.SQLException: ORA-28231
SQL error - JSP-Servlet
SQL error  Hello friends, Can we update a column with referrence to that column value. For example, the query ----------------------------------------------------------------------------- "update feedback set msgid
java servlet programming - JSP-Servlet
java servlet programming  i want 2 insert the date time into the sql column of data type datetime through servlets dynamically .How 2 do dat
Jsp ,Servlet Problem - JSP-Servlet
Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur... with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls... to execute a servlet code on tomcat server... Thanking u... Santosh  
java servlet programming - JSP-Servlet
java servlet programming  when i m inserting an image file into the sql table in a column of data type binary using prepared statement... 0xFFD8FFE000104A46494600010200006400640000FFFE001241646F6265.....in the sql table .how to display the filename
How Run JSP in Apache TomCat Server? - JSP-Servlet
How Run JSP in Apache TomCat Server?  How to Run JSP in Apache Tomcat Server? I have getting Jasper Exception which says class not found i have pasted my hello world example of JSP in the Jsp-example directory. and tried. 
jsp definition - JSP-Servlet
jsp definition  is jsp a client side programming language or server.... Here one thing u have to observe jsp page----->JSPCOMPILER---->SERVLET------->SERVER-------->HTML TO BROWSER   Hi, JSP is server
jdbc odbc sql server exception
jdbc odbc sql server exception  Hi, I am trying to use sql server with java jdbc odbc but I am getting this exception java.sql.SQLException: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '@P1
jsp page - JSP-Servlet
information that will be translated and executed by the JSP server. Types of JSP... the embedded Java declaration statements to be inserted into the Servlet class...jsp page  what are elemets and template data in jsp page??  
website deployment - JSP-Servlet
6.7 Web Server : Apache Tomcat 5.5 Database Server: FireBird Without any framework : I am able to manage to fetch records from database using Java Beans in an Arraylist and display it on Web (JSP )Page using table. Need
jsp - JSP-Servlet
jsp  1]what is CGI in jsp ? 2]advantege and disadvantage of CGI ? 3]what is servlet ? 4]what is threads ? 5]what is java server page technology...://www.roseindia.net/jsp/ http://www.roseindia.net/java/thread/ Thanks
Java runtime example - JSP-Servlet
Java runtime example  in eclipse after submiting the data throgh jsp page i got the following error..."); // Assuming your SQL Server's username is "username
Java - JSP-Servlet
Java  write a code to connect servlets-jsp page with sql database.  Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/connect-jsp-mysql.shtml http://www.roseindia.net/servlets
jsp - JSP-Servlet
://www.roseindia.net/jsp/usingbeansinjsp.shtml http://www.roseindia.net/jsp/java...-bean-counter.shtml http://www.roseindia.net/jsp/java-bean-example-jsp.shtml... is invalid. This is JSP page
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
jsp - JSP-Servlet
jsp  how to use java program in jsp ie, how to call a java program from jsp page I saw some of the sample java programs like - webapps/examples... Tomcat server....but dont know how to access those java programs(or beans
SQL Server
SQL Server  Hii, What is SQL Server ?   hello, SQL Server is a DBMS system provided by Microsoft
Servlet and Jsp - Servlet Interview Questions
Servlet and Jsp  Hi Friends, What Servlet can do that jsp cannot(can u understand , everything done in servlet --- also possible in jsp) Thanks.... and a jsp can understandable even if we dont know java. regards, madhukar
ascending or descending order in jsp using servlet - Java Server Faces Questions
ascending or descending order in jsp using servlet   My Problem is that how to sort any column in ascending or descending order,with following requirements 1. A single click on the header of a certain column causes
Java - JSP-Servlet
is pointing to U R jsp page,Enter u r <server post><JSP page> ,and u can...JSP Example in Eclipse  How to run my JSP page example in Eclipse?  To run JSP page in Eclipse Please.1. Internally Eclipse supports open
Java - JSP-Servlet
Java  How to run a JSP Program.  Hi Friend, To run JSP program, Follow these steps: 1)Install Apache Tomcat Server software in your c drive. 2)Create JSP page and save it with .jsp extension. 3)Go
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
java - JSP-Servlet
java  how to write javascript in servlet?  Hi friend, Write Javascript in servlet follow some steps: 1.Create a file Javascript file..." on the webapps->root folder. 3.Create a Servlet "JsServlet.java
Java - JSP-Servlet
;Run As->Run On Server. These options you have to select to run the servlet..... This is a general question. How to compile a servlet program? I need step by step explaination.. MoreOver,I know JAVA to some extent.. But I need to improve my
file insertion - JSP-Servlet
file insertion  How to insert and retrieve .doc files into sql server with example using jsp and servlets
Servlets vs JSP - JSP-Servlet
and servlet act as a controller. 2)JSP pages contain a mixture of HTML, Java scripts, JSP elements, and JSP directives while servlet is totally uses java code. 3)Java Server Pages is that they are document-centric. Servlets, on the other hand
jsp servlet hosting
jsp servlet hosting  Hi, What is jsp servlet hosting? Thanks   In case of jsp servlet hosting, hosting companies are providing hosting environment where client can host Java based web application on the server
JSP - JSP-Servlet
attribute SQLBean.DbBean is invalid." please verify my JSP page and class file... This is JSP page.... This one is .java file.../jsp/java-beans.shtml Thanks

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.