I'm doing a web application for one of my projects in my computer class. I have been using Apache 6.0 as my server and SQL for my database. I'm am having trouble with getting my create form which is in the view form to save with is controlled by my control to get to my model so that the database receives it. Any help will be greatly appreciated. I have a lot of code an am sorry for the long lenght i wanted to place it as a zip file
import Bb.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CreateAssignment extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
CourseList courseList = new CourseList();
String crse = "unknown";
String crsd = "unknown";
String mode = "Designer";
String tool = "Homepage";
String user = "unknown";
String newValue = null;
boolean validUser = false;
Cookie[] cookies = request.getCookies();
if ((cookies != null) && (cookies.length > 0))
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
/*
if(cookie.getName().equals("crse"))
{
crse = cookie.getValue();
}
*/
/*
if(cookie.getName().equals("mode"))
{
mode = cookie.getValue();
}
if(cookie.getName().equals("user"))
{
user = cookie.getValue();
}
*/
}
}
newValue = request.getParameter("crse");
if(newValue!=null)
{
crse = newValue;
Cookie cookie = new Cookie("crse", crse);
response.addCookie(cookie);
}
newValue = request.getParameter("crsd");
if(newValue!=null)
{
crsd = newValue;
Cookie cookie = new Cookie("crsd", crsd);
response.addCookie(cookie);
}
newValue = request.getParameter("mode");
if(newValue!=null)
{
mode = newValue;
Cookie cookie = new Cookie("mode", mode);
response.addCookie(cookie);
}
/*
newValue = request.getParameter("tool");
if(newValue!=null)
{
tool = newValue;
}
*/
newValue = request.getParameter("user");
if(newValue!=null&&newValue.length()!=0)
{
user = newValue;
}
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher("/jsp/CreateAssignmentForm.jsp");//DisplayCoursePage?crse="+crse+"&crsd="+crsd+"&user="+user+"&mode="+mode+"&tool="+tool);
rd.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DeleteAssignment extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
String crse = "unknown";
String crsd = "unknown";
String mode = "Student";
String tool = "Homepage";
String user = "unknown";
String newValue = null;
Cookie[] cookies = request.getCookies();
if ((cookies != null) && (cookies.length > 0))
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
if(cookie.getName().equals("crse"))
{
crse = cookie.getValue();
}
if(cookie.getName().equals("crsd"))
{
crsd = cookie.getValue();
}
if(cookie.getName().equals("mode"))
{
mode = cookie.getValue();
}
if(cookie.getName().equals("user"))
{
user = cookie.getValue();
}
}
}
newValue = request.getParameter("crse");
if(newValue!=null)
{
crse = newValue;
Cookie cookie = new Cookie("crse", crse);
response.addCookie(cookie);
}
newValue = request.getParameter("crsd");
if(newValue!=null)
{
crsd = newValue;
Cookie cookie = new Cookie("crsd", crsd);
response.addCookie(cookie);
}
newValue = request.getParameter("mode");
if(newValue!=null)
{
mode = newValue;
Cookie cookie = new Cookie("mode", mode);
response.addCookie(cookie);
}
newValue = request.getParameter("tool");
if(newValue!=null)
{
tool = newValue;
}
newValue = request.getParameter("user");
if(newValue!=null&&newValue.length()!=0)
{
user = newValue;
Cookie cookie = new Cookie("user", user);
response.addCookie(cookie);
}
HttpSession session = request.getSession();
//request.setAttribute("mode",mode);
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher("/jsp/index.jsp?crse="+crse+"&crsd="+crsd+"&user="+user+"&mode="+mode+"&tool="+tool);
rd.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayCoursePage extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
String crse = "unknown";
String crsd = "unknown";
String mode = "Student";
String tool = "Homepage";
String user = "unknown";
String newValue = null;
Cookie[] cookies = request.getCookies();
if ((cookies != null) && (cookies.length > 0))
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
if(cookie.getName().equals("crse"))
{
crse = cookie.getValue();
}
if(cookie.getName().equals("crsd"))
{
crsd = cookie.getValue();
}
if(cookie.getName().equals("mode"))
{
mode = cookie.getValue();
}
if(cookie.getName().equals("user"))
{
user = cookie.getValue();
}
}
}
newValue = request.getParameter("crse");
if(newValue!=null)
{
crse = newValue;
Cookie cookie = new Cookie("crse", crse);
response.addCookie(cookie);
}
newValue = request.getParameter("crsd");
if(newValue!=null)
{
crsd = newValue;
Cookie cookie = new Cookie("crsd", crsd);
response.addCookie(cookie);
}
newValue = request.getParameter("mode");
if(newValue!=null)
{
mode = newValue;
Cookie cookie = new Cookie("mode", mode);
response.addCookie(cookie);
}
newValue = request.getParameter("tool");
if(newValue!=null)
{
tool = newValue;
}
newValue = request.getParameter("user");
if(newValue!=null&&newValue.length()!=0)
{
user = newValue;
Cookie cookie = new Cookie("user", user);
response.addCookie(cookie);
}
HttpSession session = request.getSession();
//request.setAttribute("mode",mode);
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher("/jsp/index.jsp?crse="+crse+"&crsd="+crsd+"&user="+user+"&mode="+mode+"&tool="+tool);
rd.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
import Bb.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Login extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
UserList userList = new UserList();
String mode = "Student";
String tool = "Homepage";
String user = "unknown";
String pass = "unknown";
String newValue = null;
boolean validUser = false;
newValue = request.getParameter("pass");
if(newValue!=null&&newValue.length()!=0)
{
pass = newValue;
}
newValue = request.getParameter("user");
if(newValue!=null&&newValue.length()!=0)
{
user = newValue;
for(int i=0;i<userList.size();i++)
{
if(user.equals(userList.get(i).getUserid())
&&pass.equals(userList.get(i).getPassword())) validUser=true;
}
if(validUser)
{
Cookie cookie = new Cookie("user", user);
response.addCookie(cookie);
}
}
RequestDispatcher rd;
if(validUser)
{
rd = getServletContext().getRequestDispatcher("/jsp/CourseList.jsp?user="+user);
}
else
{
rd = getServletContext().getRequestDispatcher("/jsp/index.html");
}
rd.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SaveAssignment extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
String crse = "unknown";
String crsd = "unknown";
String mode = "Student";
String tool = "Homepage";
String user = "unknown";
String newValue = null;
Cookie[] cookies = request.getCookies();
if ((cookies != null) && (cookies.length > 0))
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
if(cookie.getName().equals("crse"))
{
crse = cookie.getValue();
}
if(cookie.getName().equals("crsd"))
{
crsd = cookie.getValue();
}
if(cookie.getName().equals("mode"))
{
mode = cookie.getValue();
}
if(cookie.getName().equals("user"))
{
user = cookie.getValue();
}
}
}
newValue = request.getParameter("crse");
if(newValue!=null)
{
crse = newValue;
Cookie cookie = new Cookie("crse", crse);
response.addCookie(cookie);
}
newValue = request.getParameter("crsd");
if(newValue!=null)
{
crsd = newValue;
Cookie cookie = new Cookie("crsd", crsd);
response.addCookie(cookie);
}
newValue = request.getParameter("mode");
if(newValue!=null)
{
mode = newValue;
Cookie cookie = new Cookie("mode", mode);
response.addCookie(cookie);
}
newValue = request.getParameter("tool");
if(newValue!=null)
{
tool = newValue;
}
newValue = request.getParameter("user");
if(newValue!=null&&newValue.length()!=0)
{
user = newValue;
Cookie cookie = new Cookie("user", user);
response.addCookie(cookie);
}
HttpSession session = request.getSession();
//request.setAttribute("mode",mode);
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher("/jsp/index.jsp?crse="+crse+"&crsd="+crsd+"&user="+user+"&mode="+mode+"&tool="+tool);
rd.forward(request,response);
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}
<%@ page import = "java.util.*" import="Bb.*,java.net.*,java.text.*" %>
<jsp:useBean id = "data" scope= "request" class = "Bb.CourseList" />
<html>
<head>
<link rel='stylesheet' type='text/css' href='Blackbird.css'>
</head>
<body>
<%
List list= data;
Iterator listIterator = list.iterator();
%>
<p>
<% String user = request.getParameter("user"); %>
<h2>Create Assignments</h2>
<form action = "This page.html">
<p>
<table>
<tr>
<td>Title:</td>
<td><input type = "text" size = "10"></td>
</tr>
<tr>
<td>Description:</td>
<td><input type = "text" textarea style = "height: 100px" size = "100"></td>
</tr>
<td>Instructions:</td>
<td><input type = "text" textarea style = "height: 100px" size = "100"></td>
</tr>
</table>
</form>
</body>
</html>
<%@ page import = "java.util.*" import="Bb.*,java.net.*,java.text.*" %>
<jsp:useBean id = "data" scope= "request" class = "Bb.AssignmentList" />
<html>
<head>
<body>
<%
List list= data;
Iterator listIterator = list.iterator();
%>
<p>
<h2>Assignments</h2>
<form method='post' action='/calderons/CreateAssignment'>
<input type='submit' value='Create Assignment'/>
<br>
<table border = '1' cellpadding='3' rules='groups' width='1180'>
<%
while (listIterator.hasNext())
{
Assignment assignment = (Assignment)listIterator.next();
%>
<p>
<thead BGCOLOR='#BCD2EE'>
<tr>
<th align = 'left'width='200'><u>Title</u><th>
<th align = 'left'width='200'><u>Status</u><th>
<th align = 'left'width='200'><u>Due Date</u><th>
</thead>
<tbody BGCOLOR='#FCFCFC' >
<tr>
<form action="/calderons/CreateAssignment" method="POST">
<td width = '150'><%= assignment.getTitle() %></td>
<td width = '150'></td>
<td width = '150'>ALL<td>
<td width = '150'><%= assignment.getDueDate() %></td>
<td width = '150'></td>
<input type="hidden" name= "title" value='<%= assignment.getTitle() %>'>
<input type="hidden" name= "duedate" value='<%= assignment.getDueDate() %>'>
</tbody>
</table>
<table BGCOLOR='#C0C0C0' border = '1' cellpadding='3' rules='groups' width='1180'>
<td><select name = "Select">
<option value = "-Select-">-Select-</option>
<option value = "Home Page">Home Page</option>
</select>
<input type='submit'size '12' value='>' />
<input type='submit' value='Delete' />
</tr>
</form>
</tr>
<%
}
%>
</table>
</body>
</html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='Blackbird.css'>
</head>
<body>
<img src='Blackbird.jpg' height='90'><p>
<form method='post' action='/calderons/Login'>
Username: <input type='text' width='15' name='user'><p>
Password: <input type='password' width='15' name='pass'><p>
<input type='hidden' name='mode' value='Student'>
<input type='hidden' name='tool' value='Homepage'>
<input type='submit' value='Login'>
</form>
</body>
</html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='http://localhost:8080/Backbird/jsp/Blackbird.css'>
</head>
<%
String color = "LightRed";
String mode = request.getParameter("mode");
String tool = request.getParameter("tool");
String user = request.getParameter("user");
String crse = request.getParameter("crse");
String crsd = request.getParameter("crsd");
if(mode.equals("Designer")) color = "Orange";
if(mode.equals("Professor")) color = "LightBlue";
if(mode.equals("Student")) color = "LightGreen";
%>
<body bgcolor="<%= color %>">
<table border='1' width='150%' height='150%'>
<tr>
<td colspan='2' valign='top' width='150'>
<table>
<tr>
<td width='150'>
Course: <%= crse %><br>
User: <%= user %><br>
Mode: <%= mode %><br>
</td>
<td valign='center' align='center'>
<h1><%= crsd %></h1>
</td>
</tr>
</table>
</tr>
<td width='150'>
<%@ include file="Menu.html" %>
</td>
<td valign='top'>
<%
if (request.getParameter("tool") == null) tool = "Homepage";
String next = mode+tool+".jsp";
%>
<jsp:include page="<%= next %>" />
</td>
</tr>
</body>
</html>
<html>
<head>
<link rel='stylesheet' type='text/css' href='calderons.css'>
</head>
<body>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=mode value='Designer'>
<input type='hidden' name=tool value='Homepage'>
<input type=submit value='Designer'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=mode value='Professor'>
<input type='hidden' name=tool value='Homepage'>
<input type=submit value='Professor'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=mode value='Student'>
<input type='hidden' name=tool value='Homepage'>
<input type=submit value='Student'>
</form>
<hr>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Homepage'>
<input type=submit value='Homepage'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Announcements'>
<input type=submit value='Announcements'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Assessments'>
<input type=submit value='Assessments'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Assignments'>
<input type=submit value='Assignments'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Calendar'>
<input type=submit value='Calendar'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Discussions'>
<input type=submit value='Discussions'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='LearningModules'>
<input type=submit value='LearningModules'>
</form>
<form method='post' action='/calderons/DisplayCoursePage'>
<input type='hidden' name=tool value='Mail'>
<input type=submit value='Mail'>
</form>
<form method='post' action='/calderons/jsp/index.html'>
<input type=submit value='Logout'>
</form>
</body>
</html>
Again I know it is a lot of code but please give me a direction.
package Bb;
import java.io.*;
public class Assignment implements Serializable
{
private String title = null;
private String classid = null;
private String dueDate = null;
private String dueTime = null;
private String cutoffDate = null;
private String cutoffTime = null;
private String visible = null;
private String description = null;
private String instructions = null;
public Assignment()
{
title = "";
classid = "";
dueDate = "";
dueTime = "";
cutoffDate = "";
cutoffTime = "";
visible = "";
description = "";
instructions = "";
}
public Assignment(String title, String classid, String dueDate, String dueTime, String cutoffDate, String cutoffTime, String visible, String description, String instructions )
{
this.title =title ;
this.classid =classid ;
this.dueDate =dueDate ;
this.dueTime =dueTime ;
this.cutoffDate =cutoffDate ;
this.cutoffTime =cutoffTime ;
this.visible =visible ;
this.description =description ;
this.instructions =instructions ;
}
public void setTitle (String title )
{
this.title =title ;
}
public void setClassid(String classid)
{
this.classid=classid;
}
public void setDueDate (String dueDate )
{
this.dueDate =dueDate ;
}
public void setDueTime (String dueTime )
{
this.dueTime =dueTime ;
}
public void setCutoffDate (String cutoffDate )
{
this.cutoffDate =cutoffDate ;
}
public void setCutoffTime (String cutoffTime )
{
this.cutoffTime =cutoffTime ;
}
public void setVisible (String visible )
{
this.visible =visible ;
}
public void setDescription (String description )
{
this.description =description ;
}
public void setInstructions (String instructions )
{
this.instructions =instructions ;
}
public String getTitle ()
{
return title ;
}
public String getClassid()
{
return classid;
}
public String getDueDate()
{
return dueDate;
}
public String getDueTime()
{
return dueTime;
}
public String getCutoffDate()
{
return cutoffDate;
}
public String getCutoffTime()
{
return cutoffTime;
}
public String getVisible()
{
return visible;
}
public String getDescription()
{
return description;
}
public String getInstructions()
{
return instructions;
}
}
package Bb;
import java.io.*;
import java.sql.*;
import java.util.*;
public class AssignmentList extends Vector<Assignment>
{
private String url = "jdbc:mysql://localhost/cmps480";
private String query = new String("select * from assignment;");
private static Connection connection = null;
private Statement statement = null;
private ResultSet resultSet = null;
private int columnCount = 0;
public AssignmentList()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url,"root","Alexis4");
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
columnCount = resultSet.getMetaData().getColumnCount();
while(resultSet.next())
{
add(new Assignment(resultSet.getString(1),resultSet.getString(2),resultSet.getString(3),resultSet.getString(4),resultSet.getString(5),resultSet.getString(6),resultSet.getString(7),resultSet.getString(8),resultSet.getString(9)));
}
resultSet.close();
statement.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public static Connection getConnection()
{
return connection;
}
}
package Bb;
import java.io.*;
public class Assignmentsubmission implements Serializable
{
private String classid = null;
private String title = null;
private String userid = null;
private String dateSubmitted = null;
private String timeSubmitted = null;
private String text = null;
private String feedback = null;
private String score = null;
private String graded = null;
public Assignmentsubmission()
{
classid = "";
title = "";
userid = "";
dateSubmitted = "";
timeSubmitted = "";
text = "";
feedback = "";
score = "";
graded = "";
}
public Assignmentsubmission(String classid, String title, String userid, String dateSubmitted, String timeSubmitted, String text, String feedback, String score, String graded)
{
this.classid=classid;
this.title=title;
this.userid=userid;
this.dateSubmitted=dateSubmitted;
this.timeSubmitted=timeSubmitted;
this.text=text;
this.feedback=feedback;
this.score=score;
this.graded=graded;
}
public void setClassid(String classid)
{
this.classid=classid;
}
public void setTitle(String title)
{
this.title=title;
}
public void setUserid(String userid)
{
this.userid=userid;
}
public void setDateSubmitted(String dateSubmitted)
{
this.dateSubmitted=dateSubmitted;
}
public void setTimeSubmitted(String timeSubmitted)
{
this.timeSubmitted=timeSubmitted;
}
public void setText(String text)
{
this.text=text;
}
public void setFeedback (String feedback )
{
this.feedback =feedback ;
}
public void setScore (String score )
{
this.score =score ;
}
public void setGraded (String graded )
{
this.graded =graded ;
}
public String getClassid ()
{
return classid ;
}
public String getTitle ()
{
return title;
}
public String getUserid ()
{
return userid;
}
public String getDateSubmitted()
{
return dateSubmitted;
}
public String getTimeSubmitted()
{
return timeSubmitted;
}
public String getText()
{
return text;
}
public String getFeedback()
{
return feedback;
}
public String getScore ()
{
return score ;
}
public String getGraded()
{
return graded;
}
}
package Bb;
import java.io.*;
import java.sql.*;
import java.util.*;
public class AssignmentsubmissionList extends Vector<Assignmentsubmission>
{
private String url = "jdbc:mysql://localhost/cmps480";
private String query = new String("select * from assignmentsubmission;");
private static Connection connection = null;
private Statement statement = null;
private ResultSet resultSet = null;
private int columnCount = 0;
public AssignmentsubmissionList()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url,"root","Alexis4");
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
columnCount = resultSet.getMetaData().getColumnCount();
while(resultSet.next())
{
add(new Assignmentsubmission(resultSet.getString(1),resultSet.getString(2),resultSet.getString(3),resultSet.getString(4),resultSet.getString(5),resultSet.getString(6),resultSet.getString(7),resultSet.getString(8),resultSet.getString(9)));
}
resultSet.close();
statement.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public static Connection getConnection()
{
return connection;
}
}