JSP code for registration form

JSP code for registration form

Haiiii

can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using jsp???

View Answers

December 3, 2011 at 3:02 PM

1)form.jsp:

<html>
<body>
<form name="userform" method="post" action="encrypt.jsp">
<table>
<tr><td>User Name</td><td><input type="text" name="user"></td></tr>
<tr><td>Password</td><td><input type="password" name="pass"></td></tr>
<tr><td>Confirm Password</td><td><input type="password" name="cpass"></td></tr>
<tr><td>Name</td><td><input type="text" name="name"></td></tr>
<tr><td>Phone</td><td><input type="text" name="phone"></td></tr>
<tr><td>Contact</td><td><input type="text" name="contact"></td></tr>
<tr><td><input type="submit" value="Search"></td></tr>
</table>
</form>
</body>
</html>

2)encypt.jsp

<%@page import="java.sql.*"%>
<%@page import=" java.security.MessageDigest"%>
<%
String username=request.getParameter("user");
String password=request.getParameter("pass");
String name=request.getParameter("name");
String phone=request.getParameter("phone");
String contact=request.getParameter("contact");
String algorithm="";
int ph=Integer.parseInt(phone);
byte[] unencodedPassword = password.getBytes();
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (Exception e) {}
md.reset();
md.update(unencodedPassword);
byte[] encodedPassword = md.digest();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < encodedPassword.length; i++) {
if (((int) encodedPassword[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) encodedPassword[i] & 0xff, 16));
}
String passw=buf.toString();
String connectionURL = "jdbc:mysql://localhost:3306/test";;
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
PreparedStatement ps = con.prepareStatement("INSERT INTO register(user,pass,name,phone,contact) VALUES(?,?,?,?,?)");
ps.setString(1,username);
ps.setString(2,passw);
ps.setString(3,name);
ps.setInt(4,ph);
ps.setString(5,contact);
int i = ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception ex){}

%>

December 3, 2011 at 3:03 PM

1)form.jsp:

<html>
<body>
<form name="userform" method="post" action="encrypt.jsp">
<table>
<tr><td>User Name</td><td><input type="text" name="name"></td></tr>
<tr><td>Password</td><td><input type="password" name="pass"></td></tr>
<tr><td>Address</td><td><input type="text" name="address"></td></tr>
<tr><td>Contact No</td><td><input type="text" name="phone"></td></tr>
<tr><td><input type="submit" value="Search"></td></tr>
</table>
</form>
</body>
</html>

2)encrypt.jsp:

<%@page import="java.sql.*"%>
<%@page import=" java.security.*"%>
<%@page import="javax.crypto.*"%>
<%!
private static String algorithm = "DESede";
        private static Key key = null;
        private static Cipher cipher = null;
 private static byte[] encrypt(String input)throws Exception {
            cipher.init(Cipher.ENCRYPT_MODE, key);
            byte[] inputBytes = input.getBytes();
            return cipher.doFinal(inputBytes);
        }
%>
<%!
        private static String decrypt(byte[] encryptionBytes)throws Exception {
            cipher.init(Cipher.DECRYPT_MODE, key);
            byte[] recoveredBytes =  cipher.doFinal(encryptionBytes);
            String recovered =  new String(recoveredBytes);
            return recovered;
          }
          %>
<%
String name=request.getParameter("name");
String password=request.getParameter("pass");
String address=request.getParameter("address");
String phone=request.getParameter("phone");
int ph=Integer.parseInt(phone);
StringBuffer buffer=new StringBuffer();
 key = KeyGenerator.getInstance(algorithm).generateKey();
            cipher = Cipher.getInstance(algorithm);
            String input = password;
            System.out.println("Entered: " + input);
            byte[] encryptionBytes = encrypt(input);
            String passw=new String(encryptionBytes);
String connectionURL = "jdbc:mysql://localhost:3306/test";
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
PreparedStatement ps = con.prepareStatement("INSERT INTO user(name,password,address,telno) VALUES(?,?,?,?)");
ps.setString(1,name);
ps.setString(2,passw);
ps.setString(3,address);
ps.setInt(4,ph);
int i = ps.executeUpdate();
ps.close();

}
catch(Exception ex){
System.out.println(ex);
}
try{
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from user where id='1'");
String str="";
if(rs.next()){
str=rs.getString("password");
}
out.println("Your password is: "+decrypt(str.getBytes()));
System.out.println("Your password is: "+decrypt(str.getBytes()));
}
catch(Exception e){}
%>

For the above code, we have create a database table:

CREATE TABLE `user` (                                     
          `id` bigint(255) NOT NULL auto_increment,               
          `name` varchar(255) default NULL,                       
          `password` varchar(255) default NULL,                   
          `address` varchar(255) default NULL,                    
          `telno` int(255) default NULL,                          
          PRIMARY KEY  (`id`)                                     
        );









Related Tutorials/Questions & Answers:
JSP code for registration form
JSP code for registration form  Haiiii can u please tell me how to encrypt password field in registration form and to compare both password and confirm password fields using jsp
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml
userregistration code -- http://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml  While running this application on netbeans7.0 , i am getting the following error: message /userregister/ description The requested
Advertisements
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration... RESEND THE CODE org.apache.jasper.JasperException: java.lang.NumberFormatException... in database as text and set the mobile field or telephone field as string in your code
HTML(Registration form) to Jsp to stored into MS ACCESS database
HTML(Registration form) to Jsp to stored into MS ACCESS database  i... database by using jsp code.i want to urgent jsp code. please urgent sir. thank you for waiting that code. This is My Html page Link
html code for student registration form
html code for student registration form Here is an example of html code for student registration form. In this example, we have displayed many text fields... Source Code Student registration form Download Source CodeADS_TO_REPLACE_4
User Registration Form Using JSP(JspBeans)
User Registration Form Using JSP(JspBeans)  ... of user registration form using jsp. One of the basic programming tactics... Step 1: Create a simple registration form (register.html):      
HTML Code for registration form
HTML Code for registration form Here is an example of Registration form using... code for registration form. You should add following code into your... to register on their website. The registration form is presented to the user where
Registration Form in HTML
Registration Form in HTML  User Registration Form in HTML - i wanted to design a user registration form in HTML. So, Can anyone please guide me or give me a peace of code to design a user registration form in HTML. Thanks
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
code for user registration page and login page of emails using jsp
code for user registration page and login page of emails using jsp  hiiiiiii please send me the code for user registration page and login page of email using jsp and servlets and also code for database connectivity to oracle
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  ... of data for login purpose. I have created 1 form in JSP netbeans with both username... a student. I have been given a task to create registration page with username &
Login form and registration
Login form and registration  I need a complete code for ligin and new user registration form and validation
popup registration form
popup registration form  hi i want a code for popup registration form.when user click a button popup form will appear.thanks.
Registration Form
Registration Form  Hi Friends I am Working on a small project.I have to create a Registration page using MVC pattern where i have to insert data username,password,date of birth,Mobile number number into database. How to insert
registration form
registration form  Hii.. I have to design one registration page... style="margin-top : 100px" align="center" border=0&gt; &lt;form...;</html></p> <p>Here is the code for user already exists
to creating a registration form
to creating a registration form  how to create a registration form
java code for uploading a resume in a form - JSP-Servlet
java code for uploading a resume in a form  can anyone help me with the codes 4 uploading a resume in a registration form  Refer this link http://www.devsphere.com/mapping/docs/guide/upload.html Thanks Rajanikant
form registration on JavaScript
form registration on JavaScript   i want form of registration on JavaScript > < check the name is string or number & if the name number output error >> and the same of email and birthday and country >> <
AJAX REGISTRATION FORM
AJAX REGISTRATION FORM  I have implemented user name, check and state selection using ajax, in the html registration form. I am loading two XML... either username or state. How to implement both in same registration form could any
to create registration form
://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml... to do an assignment on to create an registration form with 20 input fields by using... just beginner for this language   Here is a jsp code that accepts several
How to Create Student Registration Form with HTML Code?
How to Create Student Registration Form with HTML Code? At present... will learn to create a student registration form using html code in easy steps... In this tutorial for writing html code for student registration form JavaScript validation
user Registration form using bean
user Registration form using bean   In this code,password and confirm password does n't matches.Every time an error occured if i entered same string for both.Please help to sort my problem
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
creating web page for form registration
creating web page for form registration  I am creating web page for form registration to my department ..I have to Reprint the Application Form (i.e... anyone post sample code
how to create a user registration form in php
how to create a user registration form in php  how to create a user registration form in php
jsp excel code - JSP-Servlet
jsp excel code  Hi how to insert form data into excel file using jsp?  Hi Friend, Try the following code: 1)register.jsp: Registration Form First Name: Last Name: User Name: Password
Developing User Registration Form
how to develop the User Registration Form and related JSP files. This User... code are described further down in this section. Registration JSP (userRegister.jsp) The Registration JSP (userRegister.jsp) generates the registration form
web page for form registration to my department
web page for form registration to my department  I am creating web page for form registration to my department ..I have to Reprint the Application Form (i.e Download the PDf File from the Database ) , when the user gives
registration form using oop concept
registration form using oop concept  I would like to write a program student registration form at kindergartens and display the information... the output?   Registration Form: import javax.swing.*; import java.awt.
Login & Registration - JSP-Servlet
Login & Registration  Pls tell how can create login and registration step by step in servlet. how can show user data in servlet and how can add...://www.roseindia.net/jsp/loginbean.shtml Hope that the above links will be helpful
database spring registration form
; } } rgistration.jsp 5 We are create user registration jsp form we are many field...database spring registration form We are going to discuss about  database spring registration form. We have created simple spring registration form
How do I compile the registration form?
How do I compile the registration form?  How do I compile the registration form as stated at the bottom of the following page (URL is below). Do I...://www.roseindia.net/struts/hibernate-spring/user-registration-action.shtml
jsp form
jsp form  hai... GoodEvening I have one doubt on jsp.please wil u clarify it. how to move one jsp form to another jsp form with out using forward... page. 1)form1.jsp: <html> <form method="post" action="form2.jsp">
jsp form
jsp form  hi i have one excuted jsp form.and in that the data should be dispaly on another jsp form.please help me thanks in advance   Hi Friend, Try this: 1)form1.jsp: <html> <form method="post" action
database connectivity in jsp form
database connectivity in jsp form We are going to create jsp registration form database. We first create simple registration form. All data ...;/html> Form ADS_TO_REPLACE_2 Download Source Code
jsp code - JSP-Servlet
: RoseIndia left:Add,delete right:employee Registration form Footer...jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page
jsp code - JSP-Servlet
: RoseIndia left:Add,delete right:employee Registration form Footer...jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page
Example of handling form in JSP
the form in JSP. Can you tell me the the example of handling form in JSP. How to handle a form in JSP? Thanks   Hi, In JSP page you can get the values of form data with the following code: String value = request.getParameter
jsp code
jsp code  what are the jsp code for view page in online journal
How to handle a form in JSP
and the procedure of handling the form through the JSP code. This section provides JSP code which used the HTML code for creating a form and this form is handled... How to handle a form in JSP   
java code for registration and login pages, mysql as a bankend.
java code for registration and login pages, mysql as a bankend.  please send me the java code for registration and login pages and to store the data in mysql
JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code... visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml www.roseindia.net/jsp/searchbook.shtml
How to create a form in JSP
of the creation of a form through the HTML code in the JSP page. You can simply use... How to create a form in JSP   .... Following code of the JSP file is given as follows in which all the thing are usm
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
jsp code
jsp code  i want health management system project code using jsp.its urgent
search form in jsp
search form in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
java beans code in jsp - WebSevices
://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml Hope that it will be helpful...java beans code in jsp  can you tell me how to use java beans in jsp... connecting jsp page to mysql database. please send me the code for login page, myaccount
JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code

Ads