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



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

Have Programming Question? Ask it here!
 
 
 


Ramkumar P
Java servlet with jsp on sql server
1 Answer(s)      a year and 10 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?


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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
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
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
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
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
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->
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
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
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
SQL Server
SQL Server  Hii, What is SQL Server ?   hello, SQL Server is a DBMS system provided by Microsoft
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
sql server - SQL
sql server  what is SQL server? & what is oracle? are they same
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
unable to connect to server - JSP-Servlet
-application-server/tomcat/install-configure.shtml Here you will get step by step installation and configuration of Apache Tomcat Server. After installation, create a web application folder inside the webapps folder and put the jsp file
sql/xml query in jsp - JSP-Servlet
sql/xml query in jsp  Sir I am coding in jsp and trying to retrieve xml data from db2 using sql/xml query in jsp but getting no result. When running jsp file in browser the output
Searching a word file on server in JSP - JSP-Servlet
Searching a word file on server in JSP  Seacrhing a word file on server side using JSP. I am Apache Tomcat Server. Please help me Sir
sql server - SQL
sql server  How many no of tables can be joined in same sql server
server database connection - JSP-Servlet
server database connection  sir generally we will connect to the database by using the following steps 1.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver... the server while we are using client system.There we have to specify the "HOST STRING
Sun App Server - JSP-Servlet
Sun App Server  Dear Roseindia Team, I am Ragavendran.R.. I need to be clarified with a thing regarding J2EE1.4 Sun App server.. As everyone is aware, the web application can be executed using say http://localhost
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
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public..."); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER;user=DTHOTA;password...("password", " "); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER", prop
Error while SQL Server connection to Java
Error while SQL Server connection to Java  import java.sql.*; public..."); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER;user=DTHOTA;password...("password", " "); con=DriverManager.getConnection("jdbc:odbc:SQL_SERVER", prop
sql/xml query in jsp - JSP-Servlet
sql/xml query in jsp  Sir Here is my code which is not working Testing JSP select id from "SYSTEM".PROFILE where xmlexists('$d[first="nitin"]' passing "SYSTEM".PROFILE.INFO as "d
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
Sql Server - SQL
sql server trigger example  Can any one tell me the live example of triggers in SQL Server?   if u click pistal trigger ,it auotmatically shoot bullet it's like newtons 3rd law (every action s having an equal reaction
To retrieve image from SQL Server Database - Java Server Faces Questions
To retrieve image from SQL Server Database  Sir/Madam, I am trying to retrieve image from SQL Server 2000 database in Visual Web JSF Page using... or in Image Component. please help me in retrieving and displaying image from SQL Server
JSP with java/servlet - JSP-Servlet
(java bean or servlet) to fecth the database. Jsp would get the data from...JSP with java/servlet  Thanks Deepak for your answere to my previous.../servlet-jsp-data-list.shtml Hope that it will be helpful for you. Thanks
JAVA JSP and Servlet - JSP-Servlet
JAVA JSP and Servlet  for sending mail through lan without intenet and also chatting facility for online users using Java JSP & SERVLET code.  Hi Friend, Please visit the following links: http://www.roseindia.net
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
image uploading perminssion in server - JSP-Servlet
Status 500 - type Exception report message description The server.... exception org.apache.jasper.JasperException: Exception in JSP: /jsp...(MultipartRequest.java:89) org.apache.jsp.jsp.BSAdminVendorEdit_jsp
JAVA SERVLET - JSP-Servlet
JAVA SERVLET Log   Hi, A servlet file which create the log files ,then writing values to the list & log, we should have a thousand separator and no decimal values. This means instead of writing 986300.0 in the Log file
java - JSP-Servlet
java  why is required to write both jsp and servlet in a application of java
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.  
image uploading perminssion in server - JSP-Servlet
problem image uploading in server that i working fine in my system, OS Ubuntu. but in server it is showing following error...) com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:89) org.apache.jsp.jsp.BSAdminProductsCreate_jsp
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
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. 
java,servlet,jsp - JSP-Servlet
java,servlet,jsp   i am doing a project on online examination system and in that there are problems that-- 1.i want to disable the back,forward and refresh button.Please give me the code for google crome browser. 2.suppose
reading a file on server side - JSP-Servlet
reading a file on server side  Thank you sir for replying with the solution of my first question. Now i am facing some problem in renameing & reading a word file in JSP which is uploaded by client. please help me
image uploading perminssion in server - JSP-Servlet
image uploading perminssion in server  thanks dear, but i am working in Linux Ubuntu, how can i set the path in server. my problem is i am not able to access the folders wherever we are uploading the files, we are not able
image uploading perminssion in server - JSP-Servlet
("file.separator"); int last=path.lastIndexOf(seperator+"jsp"); String...://www.roseindia.net/jsp/file_upload/employee_upload_profile_image.shtml Thanks
XML in SQL Server
XML in SQL Server  Hi..... please anyone tell me about What is the purpose of FOR XML in SQL Server? Thanks
Advertisements
 

 

 

DMCA.com