0 Replies - 897 Views - Last Post: 07 April 2010 - 09:25 AM

#1 newkid34   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 22-November 09

XHTML Page with JSP to Write to MySQL

Posted 07 April 2010 - 09:25 AM

So i need to write the JSP code for a webpage to access and either Delete or Add a name to a database.
Here is the code for the basic form i have.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="windows-1250"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>MySQL and Javascript</title>
</head>

<body>
<p>
<center><h1>Form For Database Input or Deletion</h1></center>
</p>
<p>
<form>
Name: <input type="text" name="first"></input>
<input type="radio" name="deletion"> Delete </input>
<input type="radio" name="insertion"> Insert </input>
</form>


</body>
</html>


And here is the code i have for establishing a connection to the database

<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://sql2.njit.edu:3306/<database_name>";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>

<html><body>

<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "<username>", "<password");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM <tablename>");

rs.close();
%>

</body></html>



Here's the project description

Make a Database with a table named Members with a single attribute clubMembers. An HTML Form allows members to be added to the data base by transmitting a Form input variable newMemberName to a designated JSP program which adds members to the database. Verify the additions by manually displaying the database tables before and after additions. Test and Document appropriately. You will be using the MySql database.

1. Add a password field to the form and protect the database with a password, rejecting access if the password fails. Use POST method on form so password is not overtly exposed in the query string.

2. Use a radio button option on the form to allow the user to either insert or delete a member from the database. You can assume that if the user provides a name to be removed then that name is actually already in the database and is unique.

so where do i need help with?

Creating JSP code to find the value in the Text box, check if the value is to be added or deleted via the radio buttons, then post it to the MySQL database. I'm afraid to even get near the password thing unless someone has an easy trick to get that done...

Any help is appreciated

Is This A Good Question/Topic? 0
  • +

Page 1 of 1