Skip to content

Commit 4e8c85c

Browse files
Database connection and registation page complete
0 parents  commit 4e8c85c

20 files changed

+682
-0
lines changed

.classpath

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" path="src/main/java"/>
9+
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0">
10+
<attributes>
11+
<attribute name="owner.project.facets" value="jst.web"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
15+
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
16+
<classpathentry kind="lib" path="src/main/webapp/WEB-INF/lib/mysql-connector-java-5.1.48-bin.jar"/>
17+
<classpathentry kind="output" path="build/classes"/>
18+
</classpath>

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build/

.project

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Authentication Module Java Web Project</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.wst.validation.validationbuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
26+
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
27+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
28+
<nature>org.eclipse.jdt.core.javanature</nature>
29+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
30+
</natures>
31+
</projectDescription>

.settings/.jsdtscope

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/>
4+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
6+
<attributes>
7+
<attribute name="hide" value="true"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
11+
<classpathentry kind="output" path=""/>
12+
</classpath>

.settings/org.eclipse.jdt.core.prefs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=15
4+
org.eclipse.jdt.core.compiler.compliance=15
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
7+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
9+
org.eclipse.jdt.core.compiler.release=enabled
10+
org.eclipse.jdt.core.compiler.source=15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
2+
<wb-module deploy-name="Authentication Module Java Web Project">
3+
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
4+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
5+
<property name="context-root" value="Authentication_Module_Java_Web_Project"/>
6+
<property name="java-output-path" value="/Authentication Module Java Web Project/build/classes"/>
7+
</wb-module>
8+
</project-modules>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<runtime name="Apache Tomcat v9.0"/>
4+
<fixed facet="jst.web"/>
5+
<fixed facet="java"/>
6+
<fixed facet="wst.jsdt.web"/>
7+
<installed facet="java" version="15"/>
8+
<installed facet="jst.web" version="4.0"/>
9+
<installed facet="wst.jsdt.web" version="1.0"/>
10+
</faceted-project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Window

src/main/java/com/DAO/UserDAO.java

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.DAO;
2+
3+
import java.sql.Connection;
4+
import java.sql.PreparedStatement;
5+
6+
import com.entites.*;
7+
8+
public class UserDAO {
9+
10+
11+
private Connection conn;
12+
13+
public UserDAO(Connection conn) {
14+
super();
15+
this.conn = conn;
16+
}
17+
18+
public boolean userRegister(User us)
19+
{
20+
21+
boolean f= false;
22+
23+
24+
try {
25+
26+
String query="insert into user(name,email,password) values(?,?,?)";
27+
PreparedStatement ps=conn.prepareStatement(query);
28+
ps.setString(1, us.getName());
29+
ps.setString(2, us.getEmail());
30+
ps.setString(3, us.getPassword());
31+
32+
33+
ps.executeUpdate();
34+
f=true;
35+
36+
}catch (Exception e) {
37+
e.printStackTrace();
38+
}
39+
40+
41+
42+
return f;
43+
44+
}
45+
46+
47+
48+
49+
50+
}

src/main/java/com/DB/DBConnect.java

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.DB;
2+
3+
//import java.sql.Connection;
4+
//import java.sql.DriverManager;
5+
import java.sql.*;
6+
public class DBConnect {
7+
8+
9+
10+
11+
12+
13+
private static Connection conn;
14+
15+
public static Connection getConnection() {
16+
17+
18+
try {
19+
20+
if(conn==null) {
21+
Class.forName("com.mysql.jdbc.Driver");
22+
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/login","root","1234");
23+
24+
25+
}
26+
27+
28+
29+
//return con;
30+
31+
}catch(Exception e) {
32+
33+
e.printStackTrace();
34+
35+
36+
}
37+
38+
return conn;
39+
40+
41+
}
42+
43+
44+
45+
46+
47+
48+
49+
}

src/main/java/com/entites/User.java

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.entites;
2+
3+
public class User {
4+
5+
private int id;
6+
private String name;
7+
private String email;
8+
private String password;
9+
public User() {
10+
super();
11+
// TODO Auto-generated constructor stub
12+
}
13+
public User(int id, String name, String email, String password) {
14+
super();
15+
this.id = id;
16+
this.name = name;
17+
this.email = email;
18+
this.password = password;
19+
}
20+
public User(String name, String email, String password) {
21+
super();
22+
this.name = name;
23+
this.email = email;
24+
this.password = password;
25+
}
26+
public int getId() {
27+
return id;
28+
}
29+
public void setId(int id) {
30+
this.id = id;
31+
}
32+
public String getName() {
33+
return name;
34+
}
35+
public void setName(String name) {
36+
this.name = name;
37+
}
38+
public String getEmail() {
39+
return email;
40+
}
41+
public void setEmail(String email) {
42+
this.email = email;
43+
}
44+
public String getPassword() {
45+
return password;
46+
}
47+
public void setPassword(String password) {
48+
this.password = password;
49+
}
50+
51+
52+
53+
54+
55+
56+
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.servlet;
2+
3+
import java.io.IOException;
4+
import java.io.PrintWriter;
5+
6+
import javax.servlet.ServletException;
7+
import javax.servlet.annotation.WebServlet;
8+
import javax.servlet.http.HttpServlet;
9+
import javax.servlet.http.HttpServletRequest;
10+
import javax.servlet.http.HttpServletResponse;
11+
import javax.servlet.http.HttpSession;
12+
13+
import com.DAO.UserDAO;
14+
import com.DB.DBConnect;
15+
import com.entites.User;
16+
17+
/**
18+
* Servlet implementation class registerServlet
19+
*/
20+
@WebServlet("/registerServlet")
21+
public class registerServlet extends HttpServlet {
22+
private static final long serialVersionUID = 1L;
23+
24+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
25+
throws ServletException, IOException {
26+
27+
28+
String name =request.getParameter("uname");
29+
String email =request.getParameter("email");
30+
String password =request.getParameter("password");
31+
32+
User us=new User();
33+
34+
us.setName(name);
35+
us.setEmail(email);
36+
us.setPassword(password);
37+
38+
UserDAO dao=new UserDAO(DBConnect.getConnection());
39+
boolean f=dao.userRegister(us);
40+
41+
42+
if(true) {
43+
44+
// PrintWriter out=response.getWriter();
45+
// out.println("Data insert Sucessfully");
46+
HttpSession session=request.getSession();
47+
session.setAttribute("reg-msg", "Rsgistation Sucessfully..!");
48+
response.sendRedirect("register.jsp");
49+
50+
51+
52+
}else {
53+
54+
HttpSession session=request.getSession();
55+
session.setAttribute("error-msg", "Something Wrong..!");
56+
response.sendRedirect("register.jsp");
57+
}
58+
59+
60+
}
61+
62+
}

src/main/webapp/META-INF/MANIFEST.MF

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+
Binary file not shown.

src/main/webapp/WEB-INF/web.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
3+
<display-name>Authentication Module Java Web Project</display-name>
4+
<welcome-file-list>
5+
<welcome-file>index.html</welcome-file>
6+
<welcome-file>index.htm</welcome-file>
7+
<welcome-file>index.jsp</welcome-file>
8+
<welcome-file>default.html</welcome-file>
9+
<welcome-file>default.htm</welcome-file>
10+
<welcome-file>default.jsp</welcome-file>
11+
</welcome-file-list>
12+
</web-app>

src/main/webapp/css/style.css

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.bg-custom{
2+
3+
background:#f57c00 ;
4+
}
5+
6+
.c-head{
7+
8+
background:#ffb300 ;
9+
10+
}

0 commit comments

Comments
 (0)