Java
  Home arrow Java arrow Page 7 - The JSP Files (part 5): No Forwarding ...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

The JSP Files (part 5): No Forwarding Address
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2001-03-19

    Table of Contents:
  • The JSP Files (part 5): No Forwarding Address
  • Dumped!
  • The Scenic Route
  • One Step At A Time
  • New Friends
  • No Forwarding Address
  • Cleaning Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    The JSP Files (part 5): No Forwarding Address - Cleaning Up


    (Page 7 of 7 )

    Finally, it's time to do a little routine maintenance. This example demonstrates how to use the DELETE statement to delete a particular entry. Again, the basic principles remain the same, with only the query string changing.

    First, the initial list page has to be altered to include a link to delete a specific entry - this is similar to the manner in which the "edit this entry" link was added. Assuming that's taken care of, the script "delete.jsp" should be called with the number of the record to be deleted. So, just as you have the link



    "<a href=edit.jsp?id=" + ID + ">edit this entry</a>"

    you will now have the additional link

    "<a href=delete.jsp?id=" + ID + ">delete this entry</a>"

    Let's take a look at "delete.jsp".

    <html> <head> <basefont face="Arial"> </head> <body> <center> <%@ page language="java" import="java.sql.*" %> <% // delete.jsp // form data String fid = request.getParameter("id"); int id = Integer.parseInt(fid); // database parameters String host="localhost"; String user="us867"; String pass="jsf84d"; String db="db876"; String conn; Class.forName("org.gjt.mm.mysql.Driver"); // create connection string conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" + pass; // pass database parameters to JDBC driver Connection Conn = DriverManager.getConnection(conn); // query statement Statement SQLStatement = Conn.createStatement(); // generate query String Query = "DELETE FROM abook WHERE id=" + id; // get result code int SQLStatus = SQLStatement.executeUpdate(Query); if(SQLStatus != 0) { out.println("Entry successfully deleted."); } else { out.println("Error! Please try again."); } // close connection SQLStatement.close(); Conn.close(); %> </center> </body> </html>

    And that's about all we have for this issue of The JSP Files. Next time, we'll be taking a look at the HTTP session management capabilities available in JSP - so make sure you come back for that one!
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway