Question

In: Computer Science

I need a sample of code of the below senario in Java with Spring Boot framework...

I need a sample of code of the below senario in Java with Spring Boot framework

Create a login and register page and user be able to register and then log in.

Data need to be stored from the user are:

Id, First Name, Last Name, DOB, Email, and Phone Number.

if user inputs the wrong credential system displays error.

please use JSPs. and JSTL dependencies

Solutions

Expert Solution

A USER NEED PASSWORD WITH HIS USER ID TO LOGIN OR SIGN WHICH YOU HAVE NOT MENTIONED IN YOUR QUESTION ANYWAY I AM TELLING YOU THIS WHOLE PROCESS WITH THE PASSWORD OKK MY FRIEND LETS UNDERSTAND OUR NEED FIRST WHAT WE HAVE TO DO FOR MAKING A SIGN UP AND A LOGIN PAGE ----

For making this type of page you need to develop several files like for frontend user side u have to make Two  HTML FORM and by USING THAT FORMS that user can signup by filling his details and after that it will login by using that credentials --

Data of user's  signup form will be saved to database for further LOGIN process and in ;LOGIN PROCESS WE MATCH  THE GIVEN FOEM DATA FROM OUR DATABASE AND IF IT MATCHED THEN USER WILL LOGIN SUCCESFULLY ELSE if any one insert's a wrong credential then it will get "Invalid password or username." message . okk lets we start-----

index.html // your login form

<!DOCTYPE html>
<html>
<head>
<title>Login Form</title>
</head>
<body>
<form action="login.jsp" method="post">
id :<input type="text" name="usr" /><br>
password :<input type="password" name="password" /><br>
<input type="submit" /> </form>
<p>New user. <a href="signup.html">signup Here</a>. </body>
</html>

login.jsp

<%@ page language="java" contentType="text/html;"%>
<%@page import="java.sql.*,java.util.*"%>
<%
String userid=request.getParameter("userid");
session.putValue("userid",userid);
String password=request.getParameter("password");
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","");
Statement st= con.createStatement();
ResultSet rs=st.executeQuery("select * from users where userid='"+userid+"' and password='"+password+"'");
try{
rs.next();
if(rs.getString("password").equals(password)&&rs.getString("userid").equals(userid))
{
out.println("Welcome " +userid);
}
else{
out.println("Invalid password or username.");
}
}
catch (Exception e) {
e.printStackTrace();
}
%>

signup.html // [your Sign up form ]

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>new registration</title>
</head>
<body>
<form action="signupdata.jsp" method="post">

User ID :<input type="text" name="userid" />

password :<input type="password" name="password" />
First name :<input type="text" name="fname" />
Last name :<input type="text" name="lname" />

Birthday: <input type="date" name="bday"/>
Email ID :<input type="text" name="email" />

Phone no: <input type="tel" name="usrtel"/>

<input type="submit" />
</form>
</body>
</html>

This file will save your signup form data to your database-----

signupdata.jsp

<%@ page language="java" %>
<%@page import="java.sql.*,java.util.*"%>
<%

String userid=request.getParameter("userid");

String password=request.getParameter("password");
String fname=request.getParameter("fname");
String lname=request.getParameter("lname");

String bday=request.getParameter("bday");
String email=request.getParameter("email");

String usrtel=request.getParameter("usrtel");



{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/student", "root", "");
Statement st=conn.createStatement();
int i=st.executeUpdate("insert into users(userid,password,fname,lname,bday,email,usrtel)values('"+userid+"','"+password+"','"+fname+"','"+lname+"',''+bday+"",'"+email+"',""+usrtel+"")");
out.println("registered succesfully ! Please <a href='index.html'>Login</a> ");
}
catch(Exception e)
{
System.out.print(e);
e.printStackTrace();
}
%>

DON'T FORGET TO UPVOTE IF YOU FIND IT USEFUL FOR YOURSELF

AND IF YOU HAVE ANY DOUBT PLEASE ASK IN COMMENT


Related Solutions

I need a full java code. And I need it in GUI With the mathematics you...
I need a full java code. And I need it in GUI With the mathematics you have studied so far in your education you have worked with polynomials. Polynomials are used to describe curves of various types; people use them in the real world to graph curves. For example, roller coaster designers may use polynomials to describe the curves in their rides. Polynomials appear in many areas of mathematics and science. Write a program which finds an approximate solution to...
Java question: I need to fix a point class (code below) Thank you! /** * A...
Java question: I need to fix a point class (code below) Thank you! /** * A point, implemented as a location without a shape. */ public class Point extends Location { // TODO your job // HINT: use a circle with radius 0 as the shape! public Point(final int x, final int y) { super(-1, -1, null); assert x >= 0; assert y >= 0; } }
JAVA JAVA JAVA Hey i need to find a java code for my homework, this is...
JAVA JAVA JAVA Hey i need to find a java code for my homework, this is my first java homework so for you i don't think it will be hard for you. (basic stuff) the problem: Write a complete Java program The transport Company in which you are the engineer responsible of operations for the optimization of the autonomous transport of liquid bulk goods, got a design contract for an automated intelligent transport management system that are autonomous trucks which...
Java homework problem: I need the code to be able to have a message if I...
Java homework problem: I need the code to be able to have a message if I type in a letter instead of a number. For example, " Please input only numbers". Then, I should be able to go back and type a number. import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class LoginGui {    static JFrame frame = new JFrame("JFrame Example");    public static void main(String s[]) {        JPanel panel...
I need an idea of Java code that will convert an integer (1 to 3,999) into...
I need an idea of Java code that will convert an integer (1 to 3,999) into roman numerals using if statements; arrays and loops sadly aren't allowed and that's all I can come up with.
(This is for java) I need to rewrite this code that uses a while loop. public...
(This is for java) I need to rewrite this code that uses a while loop. public class Practice6 {      public static void main (String [] args) {         int sum = 2, i=2;        do { sum *= 6;    i++;    } while (i < 20); System.out.println("Total is: " + sum); }
I need to make this into a Java Code: Write a program that prompts the user...
I need to make this into a Java Code: Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = πr2 sphereArea = 4πr2 sphereVolume = 43πr3 You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area...
Hello, I need to come up with the java code for a program that looks at...
Hello, I need to come up with the java code for a program that looks at bank Account ID's and checks if it is in the frame work of Letter followed by 4 numbers, so for example "A001". I need it to be its own method, named checkAccountID() that passes the accountID as an argument to check if it is in that framework of one letter followed by 4 numbers. Any ideas?
JAVA CODE BEGINNERS, I already have the DEMO CLASS(NEED YOU TO USE), I need you to...
JAVA CODE BEGINNERS, I already have the DEMO CLASS(NEED YOU TO USE), I need you to use all methods, also switch statements. Write a Temperature class. The class will have three conversion methods: toCelsius(), toKelvin() and toFahrenheit(). These methods will return a Temperature in those three scales equal to the this temperature. Note that the value of this is not changed in these conversions. In addition to these three conversion methods the class will have methods add(Temperature), subtract(Temperature), multiply(Temperature), and...
I need to do a framework presentation on the topic below. The presentation will take 3...
I need to do a framework presentation on the topic below. The presentation will take 3 minutes: V- World War II: The pre-World War II period was a period of great economic suffering all over the world called the Great Depression. Many people were unemployed and struggling to survive. These unstable governments and unrest all over the world created the reasons for World War II. As this crisis contributed to the deterioration of the economy of democratic capitalist countries, which...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT