// ====================================================================
// Copyright (c) 1997, 1998 The Apache Group. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
//
// 3. All advertising materials mentioning features or use of this
// software must display the following acknowledgment:
// "This product includes software developed by the Apache Group
// for use in the Apache HTTP server project (http://www.apache.org/)."
//
// 4. The names "Apache Server" and "Apache Group" must not be used to
// endorse or promote products derived from this software without
// prior written permission.
//
// 5. Redistributions of any form whatsoever must retain the following
// acknowledgment:
// "This product includes software developed by the Apache Group
// for use in the Apache HTTP server project (http://www.apache.org/)."
//
// THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
// EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
// ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
// ====================================================================
//
// This software consists of voluntary contributions made by many
// individuals on behalf of the Apache Group and was originally based
// on public domain software written at the National Center for
// Supercomputing Applications, University of Illinois, Urbana-Champaign.
// For more information on the Apache Group and the Apache HTTP server
// project, please see .
// JServ - Serve up Java servlets
// by Alexei Kosut
// Parts are based on examples from _Java in a Nutshell_ by David Flanagan:
// Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or implied.
// ServletMonitor.java:
// - org.apache.jserv.test.ServletMonitor
package gs.conn;
import java.util.Enumeration;
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpUtils;
import gs.db.update;
import gs.db.student;
/**
*/
public class signup extends HttpServlet {
/**
* Service the request.
*
* @exception ServletException if there is any sort of Exception
*
*/
public void doPost(HttpServletRequest req,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("");
out.println("Signup");
out.println("");
out.println("");
String ssn = req.getParameter("ssn1")
+req.getParameter("ssn2")
+req.getParameter("ssn3");
String firstname = req.getParameter("firstname");
String midname = req.getParameter("midname");
String lastname = req.getParameter("lastname");
String gspwd = req.getParameter("gspwd");
String confirm = req.getParameter("confirmgspwd");
if(ssn.equals("") || firstname.equals("") || lastname.equals("")
|| gspwd.equals("") || confirm.equals(""))
out.println("
ERROR: Please enter in all the fields in red!");
else if (ssn.length() != 9)
out.println("
ERROR: Social security number must be 9 digits long!");
else if (!gspwd.equals(confirm))
out.println("
ERROR: Passwords do not match!");
else if (!gspwd.length() < 4)
out.println("
ERROR: Password must be at least 4 characters long!");
else {
String student_id= req.getParameter("student_id");
String email = req.getParameter("email");
String dept = req.getParameter("dept");
String year = req.getParameter("year");
String login = req.getParameter("login");
String unixpwd = "";
String url = req.getParameter("url");
student s = new student(ssn, gspwd, firstname, midname, lastname,
student_id, email, dept, year, login, unixpwd, url);
try {
update.updateData( s.insertSQL() );
out.println("