Skip to content

Commit ae278c8

Browse files
committed
commit3
1 parent 195e768 commit ae278c8

File tree

6 files changed

+74
-9
lines changed

6 files changed

+74
-9
lines changed

.classpath

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4+
<classpathentry kind="src" path="studentManagementSystem/src/main/java"/>
5+
<classpathentry kind="lib" path="studentManagementSystem/src/main/webapp/WEB-INF/lib/mysql-connector-java-8.0.28.jar"/>
6+
<classpathentry kind="output" path="studentManagementSystem/build/classes"/>
7+
</classpath>

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>studentManagementSystem</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.common.project.facet.core.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.jdt.core.javabuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4+
org.eclipse.jdt.core.compiler.compliance=1.7
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.source=1.7
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<faceted-project>
3+
<installed facet="java" version="1.7"/>
4+
</faceted-project>

studentManagementSystem/src/main/java/com/studentManagementSystem/AdmAccCreate.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.studentManagementSystem;
22

3+
import jakarta.servlet.RequestDispatcher;
34
import jakarta.servlet.ServletException;
45
import jakarta.servlet.http.HttpServlet;
56
import jakarta.servlet.http.HttpServletRequest;
@@ -24,19 +25,31 @@ public class AdmAccCreate extends HttpServlet {
2425
String uname;
2526
String email;
2627
String pass;
28+
String pass1;
2729

2830
@Override
2931
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
30-
func1(req,resp);
32+
try {
33+
func1(req,resp);
34+
} catch (ServletException | IOException | InterruptedException e) {
35+
// TODO Auto-generated catch block
36+
e.printStackTrace();
37+
}
3138
}
3239
@Override
3340
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
34-
func1(req,resp);
41+
try {
42+
func1(req,resp);
43+
} catch (ServletException | IOException | InterruptedException e) {
44+
// TODO Auto-generated catch block
45+
e.printStackTrace();
46+
}
3547
}
36-
void func1(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
48+
void func1(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, InterruptedException {
3749
uname=req.getParameter("uname");
3850
email=req.getParameter("email");
3951
pass=req.getParameter("pass");
52+
pass1=req.getParameter("pass1");
4053
try {
4154
Class.forName("com.mysql.jdbc.Driver");
4255
Connection con= null;
@@ -45,12 +58,19 @@ void func1(HttpServletRequest req, HttpServletResponse resp) throws ServletExcep
4558
ResultSet rs = stmt.executeQuery("select * from sms_adminlogin");
4659
PrintWriter out = resp.getWriter();
4760
if(!rs.next()) {
61+
if(pass.compareTo(pass1)==0) {
4862
PreparedStatement pst= con.prepareStatement("insert into sms_adminlogin(username,email,password) values(?,?,?)");
4963
pst.setString(1,uname);
5064
pst.setString(2,email);
5165
pst.setString(3,pass);
5266
if(pst.executeUpdate()>0)
5367
out.println("account created for admin successfully !");
68+
}else {
69+
out.println("password didn't match!");
70+
wait(2000);//
71+
RequestDispatcher requestDispatcher = req.getRequestDispatcher("/adminAcc.jsp");
72+
requestDispatcher.forward(req, resp);
73+
}
5474
}else {
5575
out.println("admin already exists!");
5676
}

studentManagementSystem/src/main/java/com/studentManagementSystem/AdminLogin.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ void func1(HttpServletRequest req, HttpServletResponse resp) throws ServletExcep
6565
out.println("Invalid username");
6666
else {
6767
boolean flag2 = false;
68-
rs.first();
69-
while(rs.next()) {
70-
if(rs.getString("email").compareTo(email)==0) {
68+
// if(!rs.isFirst())
69+
// rs.first();
70+
ResultSet rs1 = stmt.executeQuery("select * from sms_adminlogin");
71+
while(rs1.next()) {
72+
if(rs1.getString("email").compareTo(email)==0) {
7173
flag2=true;
7274
break;
7375
}
@@ -77,9 +79,11 @@ void func1(HttpServletRequest req, HttpServletResponse resp) throws ServletExcep
7779
out.println("Invalid email");
7880
else {
7981
boolean flag3 = false;
80-
rs.first();
81-
while(rs.next()) {
82-
if(rs.getString("password").compareTo(pass)==0) {
82+
// if(!rs.isFirst())
83+
// rs.first();
84+
ResultSet rs2 = stmt.executeQuery("select * from sms_adminlogin");
85+
while(rs2.next()) {
86+
if(rs2.getString("password").compareTo(pass)==0) {
8387
flag3=true;
8488
break;
8589

0 commit comments

Comments
 (0)