Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7047853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:49:17+00:00 2026-05-28T02:49:17+00:00

i’m trying to create a registration system using jsp, beans and servlets. Registration process

  • 0

i’m trying to create a registration system using jsp, beans and servlets. Registration process seems to be ok, but everytime data is supposed to be stored into database, rows are only filled with NULLs. Im a newbie in this subject so i would really apreciate your help!
Here is the code of this “system”:

ragister.html

<html>
<body >
<form action="/Ragis/proces.jsp" method=post>
<center>
<table cellpadding=2 cellspacing=1 border="1" bgcolor="lightblue">
<th bgcolor="lightblue" colspan=2>
<font size=5>User Registration</font>
<br>
<font size=2 color="red"><sup>*</sup> Required Fields</font>
</th>
<tr bgcolor="lightblue">
<td valign=top> 
<b>First Name<sup>*</sup></b> 
<br>
<input type="text" name="firstName" value="" size=20 maxlength=20></td>
<td  valign=top>
<b>Last Name<sup>*</sup></b>
<br>
<input type="text" name="lastName" value="" size=15 maxlength=20></td>
</tr>
<tr bgcolor="lightblue">
<td valign=top>
<b>E-Mail<sup>*</sup></b> 
<br>
<input type="text" name="email" value="" size=25  maxlength=125>
<br></td>
<td  valign=top>
<b>Cell Nr(9 fig.)<sup>*</sup></b> 
<br>
<input type="text" name="zip" value="" size=10  maxlength=9></td>
</tr>
<tr bgcolor="lightblue">
<td valign=top colspan=2>
<b>User Name<sup>*</sup></b>
<br>
<input type="text" name="userName" size=20 value=""  maxlength=10>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top>
<b>Password<sup>*</sup></b> 
<br>
<input type="password" name="password1" size=10 value="" maxlength=10></td>
<td  valign=top>
<b>Confirm Password<sup>*</sup></b>
<br>
<input type="password" name="password2" size=10 value="" maxlength=10></td>
<br>
</tr>
<tr bgcolor="lightblue">
<td  align=center colspan=2>
<input type="submit" value="Submit"> <input type="reset"  
value="Reset">
</td>
</tr>
</table>
</center>
</form>
</body>
</html>

proces.jsp

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

%>
<jsp:useBean id="formHandler" class="test.FormBean" scope="request">
<jsp:setProperty name="formHandler" property="*"/>
</jsp:useBean>
 <%   if (formHandler.validate()) {   
%>

<html>
<body>
<center>
<form action="/Ragis/Registration" method=post>
    <input type="submit" name="Submit" value="Submit" style="background-color:#49743D;font-weight:bold;color:#ffffff;"/>
    </form>

<table cellpadding=1 cellspacing=1 border="1" >
<th bgcolor="lightblue" colspan=2>
<font size=5>Almost done! Just press SUBMIT to finish the registration procedure!</font>
</th>
<font size=4>
<tr bgcolor="lightblue">
<td valign=top> 
<b>First Name</b> 
<br>
<jsp:getProperty name="formHandler" property="firstName"/>
</td>
<td valign=top>
<b>Last Name</b>
<br>
<jsp:getProperty name="formHandler" property="lastName"/>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top>
<b>E-Mail</b> 
<br>
<jsp:getProperty name="formHandler" property="email"/>
<br></td>
<td valign=top>
<b>Cell Nr(9 fig.)</b> 
<br>
<jsp:getProperty name="formHandler" property="zip"/>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top colspan=2>
<b>User Name</b>
<br>
<jsp:getProperty name="formHandler" property="userName"/>
</td>
</tr>
</font>
</table>
</center>
    </body>
    </html>
<%
   }  else {
%>
    <jsp:forward page="retry.jsp"/>
<%
   }
%>

retry.jsp

<jsp:useBean id="formHandler" class="test.FormBean" scope="request"/>
<html> 
<body>
<form action="/Ragis/proces.jsp" method=post>
<center>
<table cellpadding=4 cellspacing=2 border=0>
<th bgcolor="lightblue" colspan=2>
<font size=5>User Registration</font>
<br>
<font size=2 color="red"><sup>*</sup> Required Fields </font>
</th>
<tr bgcolor="lightblue">
<td valign=top> 
<B>First Name<sup>*</sup></B> 
<br>
<input type="text" name="firstName" 
value='<%=formHandler.getFirstName()%>' size=15 maxlength=20>
<br><font size=2 
color=red><%=formHandler.getErrorMsg("firstName")%></font>
</td>
<td  valign=top>
<B>Last Name<sup>*</sup></B>
<br>
<input type="text" name="lastName" 
value='<%=formHandler.getLastName()%>' size=15 maxlength=20>
<br><font size=2 
color=red><%=formHandler.getErrorMsg("lastName")%></font>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top>
<B>E-Mail<sup>*</sup></B> 
<br>
<input type="text" name="email" value='<%=formHandler.getEmail()%>' 
size=25  maxlength=125>
<br><font size=2 color=red><%=formHandler.getErrorMsg("email")%></font>
</td>
<td  valign=top>
<B>Cell Nr(9 fig.)<sup>*</sup></B> 
<br>
<input type="text" name="zip" value='<%=formHandler.getZip()%>' size=5  
maxlength=9>
<br><font size=2 color=red><%=formHandler.getErrorMsg("zip")%></font>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top colspan=2> 
<B>User Name<sup>*</sup></B>
<br>
<input type="text" name="userName" size=10 
value='<%=formHandler.getUserName()%>'  maxlength=10>
<br><font size=2 
color=red><%=formHandler.getErrorMsg("userName")%></font>
</td>
</tr>
<tr bgcolor="lightblue">
<td valign=top>
<B>Password<sup>*</sup></B> 
<br>
<input type="password" name="password1" size=10 
value='<%=formHandler.getPassword1()%>'  maxlength=10>
<br><font size=2 
color=red><%=formHandler.getErrorMsg("password1")%></font>
</td>
<td  valign=top>
<B>Confirm Password<sup>*</sup></B>
<br>
<input type="password" name="password2" size=10 
value='<%=formHandler.getPassword2()%>'  maxlength=10>
<br><font size=2 
color=red><%=formHandler.getErrorMsg("password2")%></font>
</td>
<br>
</tr>
<tr bgcolor="lightblue">
<td colspan=2 align=center>
<input type="submit" value="Submit"> 
</td>
</tr>
</table>
</center>
</form>
</body>
</html>

FormBean.java

package test;

import java.io.*;
import java.util.*;

public class FormBean {
      private String firstName;
      private String lastName;
      private String email;
      private String userName;
      private String password1;
      private String password2;
      private String zip;
      private String notify;
      private Hashtable errors;
      public boolean validate() {
        boolean bool=true;
        if (firstName.equals("")) {
          errors.put("firstName","Please enter your first name");
          firstName="";
          bool=false;
        }
        if (lastName.equals("")) {
          errors.put("lastName","Please enter your last name");
          lastName="";
          bool=false;
        }
        if (email.equals("") || (email.indexOf('@') == -1)) {
          errors.put("email","Please enter a valid email address");
          email="";
          bool=false;
        }
        if (userName.equals("")) {
          errors.put("userName","Please enter a username");
          userName="";
          bool=false;
        }
        if (password1.equals("") ) {
          errors.put("password1","Please enter a valid password");
          password1="";
          bool=false;
        }
        if (!password1.equals("") && (password2.equals("") || 
            !password1.equals(password2))) {
          errors.put("password2","Please confirm your password");
          password2="";
          bool=false;
        }
        if (zip.equals("") || zip.length() !=9 ) {
          errors.put("zip","Please enter a valid cell number");
          zip="";
          bool=false;
        } else {
          try {
            int x = Integer.parseInt(zip);
          } catch (NumberFormatException e) {
            errors.put("zip","Please enter a valid cell number");
            zip="";
            bool=false;
          }
        }
        return bool;
      }
      public String getErrorMsg(String s) {
        String errorMsg =(String)errors.get(s.trim());
        return (errorMsg == null) ? "":errorMsg;
      }
      public FormBean() {
        firstName="";
        lastName="";
        email="";
        userName="";
        password1="";
        password2="";
        zip="";
        notify="";
        errors = new Hashtable();
      }
      public String getFirstName() {
        return firstName;
      }
      public String getLastName() {
        return lastName;
      }
      public String getEmail() {
        return email;
      }
      public String getUserName() {
        return userName;
      }
      public String getPassword1() {
        return password1;
      }
      public String getPassword2() {
        return password2;
      }
      public String getZip() {
        return zip;
      }
      public String getNotify() {
        return notify;
      }
      public void setFirstName(String fname) {
        firstName =fname;
      }
      public void setLastName(String lname) {
        lastName =lname;
      }
      public void setEmail(String eml) {
        email=eml;
      }
      public void setUserName(String u) {
        userName=u;
      }
      public void  setPassword1(String p1) {
        password1=p1;
      }
      public void  setPassword2(String p2) {
        password2=p2;
      }
      public void setZip(String z) {
        zip=z;
      }
      public void setErrors(String key, String msg) {
        errors.put(key,msg);
      }
      public void setNotify(String n) {
        notify=n;
      }
    }

Registration.java

package test;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Registration extends HttpServlet{
/**
     * 
     */
    private static final long serialVersionUID = 1L;
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doPost(HttpServletRequest req, HttpServletResponse res) 
throws ServletException, IOException{
String connectionURL = "jdbc:mysql://localhost:3306/jsp";
Connection connection=null;
ResultSet rs;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String firstNamed = req.getParameter("firstName");
String lastNamed = req.getParameter("lastName");
String emaild = req.getParameter("email");
String userNamed = req.getParameter("userName");
String password1d = req.getParameter("password1");
String zipd = req.getParameter("zip");
String auto = "u";
try {
Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "root"); 
String sql = "insert into userprofile values (?,?,?,?,?,?,?)";
PreparedStatement pst = connection.prepareStatement(sql);
pst.setString(1, firstNamed);
pst.setString(2, lastNamed);
pst.setString(3, emaild);
pst.setString(4,userNamed);
pst.setString(5, password1d);
pst.setString(6, zipd);
pst.setString(7, auto);

int numRowsChanged = pst.executeUpdate();
out.println(" Welcome : ");
out.println(" '"+userNamed+"'");
pst.close();
}
catch(ClassNotFoundException e){
out.println("Couldn't load database driver: " + e.getMessage());
}
catch(SQLException e){
out.println("SQLException caught: " + e.getMessage());
}
catch (Exception e){
out.println(e);
}
finally {

try {
if (connection != null) connection.close();
}
catch (SQLException ignored){
out.println(ignored);
}
}
}
}

Briefly: ragister.html -> proces.jsp, if all info valid -> Registration.java with sending data to db, else retry.jsp with error description till everything is ok.
It seems to work preety fine, but in database i get a table with row filled with nulls 🙁

Probably i made mistake trying to read data in Registration.java.
Please, please help me and sory if i am unclear anywhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:49:18+00:00Added an answer on May 28, 2026 at 2:49 am

    You are trying to submit a blank form.

    <form action="/Ragis/Registration" method=post>
        <input type="submit" name="Submit" value="Submit" style="background-color:#49743D;font-weight:bold;color:#ffffff;"/>
        </form>
    

    There is no textfield within this form. First correct this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.