How to solve PWC6338: Cannot convert "2022-02-01" for the attribute birthDate of the bean java.util.Date?

Viewed 31

So below is the code I made to create a register form for user to register for new account.

signUp.html

<form class="user" method="post" action="signUp.jsp">
    <div class="form-group">
        <input type="text" id="name" name="name"
               placeholder="Username">
    </div>
    <div class="form-group">
        <input type="email" name="email" id="email"
               placeholder="Email Address">
    </div>
    <div class="form-group">
        <input type="text" name="phoneNumber" id="phoneNumber"
               placeholder="Contact Number">
    </div>
    <div class="form-group">
        <label for="birthday">Birthday:</label>
        <input type="date" id="birthDate" name="birthDate" class="form-control">
    </div>
    <div class="form-group">
        <select class="form-control" name="gender" id="gender">
            <option value="">Select your Gender</option>
            <option value="M">Male</option>
            <option value="F">Female</option>
            <option value="N">Not Specified</option>
        </select>
    </div>
    <div class="form-group row">
        <div class="col-sm-6 mb-3 mb-sm-0">
            <input type="password" name="password"
                   id="password" placeholder="Password">
        </div>
        <div class="col-sm-6">
            <input type="password" class="form-control"
                   id="exampleRepeatPassword" placeholder="Repeat Password">
        </div>
    </div>
    <input type="submit" class="btn btn-primary btn-user btn-block" value="Submit">
</form>

signUp.jsp


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="domain.Account" %>
<jsp:useBean id="account"
             class="domain.Account" scope="session"></jsp:useBean>
<jsp:setProperty name="account" property="*" />

<jsp:useBean id="AccountDAId" 
             class="da.AccountDA" scope="application">
</jsp:useBean>

<html>
    <body>
        <%
            AccountDAId.addRecord(account);

            out.println("Congratulation " + account.getId() + ", your registration is successful! ");

            
        %>

        <a href="signIn.html">Back to login</a>
    </body>
</html>

The problem is whenever I tried to submit the form, it shows a error org.apache.jasper.JasperException: PWC6338: Cannot convert "2022-02-01" for the attribute birthDate of the bean java.util.Date: PWC6348: Property editor not registered with the PropertyEditorManager. I believe the error is something about the ability of bean to convert a HTML date input to Java format, can someone guide me on how to solve this problem? Million thanks.

0 Answers
Related