Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
741 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project-shared-configuration> | ||
<!-- | ||
This file contains additional configuration written by modules in the NetBeans IDE. | ||
The configuration is intended to be shared among all the users of project and | ||
therefore it is assumed to be part of version control checkout. | ||
Without this configuration present, some functionality in the IDE may be limited or fail altogether. | ||
--> | ||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> | ||
<!-- | ||
Properties that influence various parts of the IDE, especially code formatting and the like. | ||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. | ||
That way multiple projects can share the same settings (useful for formatting rules for example). | ||
Any value defined here will override the pom.xml file value but is only applicable to the current project. | ||
--> | ||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>9.0-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion> | ||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server> | ||
</properties> | ||
</project-shared-configuration> |
83
pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.mycompany</groupId> | ||
<artifactId>mavenproject3</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
<name>mavenproject3</name> | ||
|
||
<properties> | ||
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-web-api</artifactId> | ||
<version>7.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>8.0.30</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
<compilerArguments> | ||
<endorseddirs>${endorsed.dir}</endorseddirs> | ||
</compilerArguments> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.3.2</version> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>2.6</version> | ||
<executions> | ||
<execution> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${endorsed.dir}</outputDirectory> | ||
<silent>true</silent> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-endorsed-api</artifactId> | ||
<version>7.0</version> | ||
<type>jar</type> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template | ||
*/ | ||
package com.ecommerce.connection; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
public class DbConnection { | ||
|
||
|
||
public static Connection connection; | ||
|
||
public static Connection getConnection(){ | ||
|
||
try{ | ||
|
||
Class.forName("com.mysql.jdbc.Driver"); | ||
connection = DriverManager.getConnection("jdbc:mysql://localhost:3368/ecommerce", "root","root"); | ||
|
||
}catch(Exception e){ | ||
e.printStackTrace(); | ||
|
||
} | ||
return (connection); | ||
} | ||
|
||
public static void CloseConnection(){ | ||
if(connection !=null){ | ||
try{ | ||
connection.close(); | ||
connection =null; | ||
}catch(SQLException ex){ | ||
ex.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
public static ResultSet getResultFromSqlQuery(String SqlQueryString){ | ||
|
||
ResultSet rs = null; | ||
try{ | ||
if (connection == null){ | ||
getConnection(); | ||
} | ||
|
||
rs = connection.createStatement().executeQuery(SqlQueryString); | ||
|
||
}catch(Exception ex){ | ||
ex.printStackTrace(); | ||
|
||
} | ||
return rs; | ||
} | ||
|
||
public static int insertUpdateFromSqlQuery(String SqlQueryString){ | ||
int i = 2; | ||
try{ | ||
if(connection ==null){ | ||
getConnection(); | ||
} | ||
|
||
i = connection.createStatement().executeUpdate(SqlQueryString); | ||
}catch(Exception ex){ | ||
ex.printStackTrace(); | ||
|
||
} | ||
return i; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template | ||
*/ | ||
package com.ecommerce.registration; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.servlet.RequestDispatcher; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
|
||
/** | ||
* | ||
* @author oladimeji | ||
*/ | ||
@WebServlet(name = "RegistrationServlet", urlPatterns = {"/register"}) | ||
public class RegistrationServlet extends HttpServlet { | ||
|
||
|
||
|
||
@Override | ||
protected void doPost(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
|
||
String yname = request.getParameter("name"); | ||
String yemail = request.getParameter("email"); | ||
String uname = request.getParameter("username"); | ||
String addy = request.getParameter("address"); | ||
String pass = request.getParameter("passwordd"); | ||
RequestDispatcher dispatcher = null; | ||
|
||
Connection con = null; | ||
try { | ||
Class.forName("com.mysql.cj.jdbc.Driver"); | ||
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ecommerce","root","rootroot" ); | ||
PreparedStatement pst = con.prepareStatement("insert into register(name,email,username,address,password) values(?,?,?,?,?) "); | ||
|
||
pst.setString(1, yname); | ||
pst.setString(2, yemail); | ||
pst.setString(3, uname); | ||
pst.setString(4, addy); | ||
pst.setString(5, pass); | ||
|
||
int rowCount = pst.executeUpdate(); | ||
dispatcher = request.getRequestDispatcher("register.jsp"); | ||
if (rowCount > 0){ | ||
request.setAttribute("status", "sucess"); | ||
response.sendRedirect("login.jsp"); | ||
|
||
} else{ | ||
request.setAttribute("status","failed"); | ||
} | ||
|
||
dispatcher.forward(request, response); | ||
} catch (Exception e){ | ||
e.printStackTrace(); | ||
|
||
} | ||
/*finally{ | ||
try{ | ||
con.close(); | ||
}catch(SQLException e){ | ||
e.printStackTrace(); | ||
} | ||
}*/ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Context path="/mavenproject3"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<%-- | ||
Document : index | ||
Created on : 13 Aug 2022, 23:19:17 | ||
Author : oladimeji | ||
--%> | ||
|
||
<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>JSP Page</title> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
<body> | ||
<ul> | ||
<li><a href="#home">Home</a></li> | ||
<li><a href="login.jsp">Log-in</a></li> | ||
<li><a href="register.jsp">Sign-up</a></li> | ||
<li><a href="#cart">Cart</a></li> | ||
</ul> | ||
|
||
<div> | ||
|
||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<%-- | ||
Document : login | ||
Created on : 14 Aug 2022, 01:47:18 | ||
Author : oladimeji | ||
--%> | ||
|
||
<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>JSP Page</title> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
<body> | ||
<ul> | ||
<li><a href="index.jsp">Home</a></li> | ||
<li><a href="login.jsp">Log-in</a></li> | ||
<li><a href="register.jsp">Sign-up</a></li> | ||
<li><a href="#cart">Cart</a></li> | ||
</ul> | ||
|
||
<div class="signup-header"> | ||
<h2>Login</h2> | ||
</div> | ||
|
||
<form method="post" action="Controller"> | ||
|
||
<input type="hidden" name="page" value="login-form"> | ||
|
||
<!-- Validations errors --> | ||
<font color="#F24638"><c:out value="${msg }"></c:out></font> | ||
|
||
<div class="signup-group"> | ||
<label>Username</label> | ||
<input type="text" name="username" placeholder="Your Username"> | ||
</div> | ||
<div class="signup-group"> | ||
<label>Password</label> | ||
<input type="password" name="password" placeholder="Enter password"> | ||
</div> | ||
<div class="signup-group"> | ||
<button type="submit" name="login" class="signup-btn">Log in</button> | ||
</div> | ||
<p> | ||
New to Computer For You? <a href="register.jsp" style="color:#F24638;">Create Account</a> | ||
</p> | ||
</form> | ||
</body> | ||
</html> |
Oops, something went wrong.