• Register
0 votes
82 views

Problem :

I am trying to run my registration jsp page with the servlet. But it is throwing following error:

The server encountered an internal error that prevented it from fulfilling this request.

java.lang.NullPointerException

com.java.task11.utils.ValidateUtil.EmailVal(ValidateUtil.java:44)
com.java.task11.webapp.RegistrServlet.validateInputs(RegistrServlet.java:105)
com.java.task11.webapp. RegistrServlet.processRegistration(RegistrServlet.java:77)
com.java.task11.webapp. RegistrServlet.doPost(RegistrServlet.java:49)
javax.servlet.http.HttpServlet.service(HttpServlet.java:700)
javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:62)

I am unable to figure out why this is happening?

Any clues?

6 5 3
7,540 points

1 Answer

0 votes

Solution :

Please find the solution for your error as follows:

if (ValidateUtil.isNullOrEmpty(lastName)) {
registrationErrors.add(ValidateErrors.LAST_NAME);
 }
if (!ValidateUtil.isEmailValid(email)) {
registrationErrors.add(ValidateErrors.EMAIL);
}

I have gone through your problem in above code snippet you are checking for null or empty value on only lastname, but not on isEmailValid for empty value. So you will need something like below code change that will help you.

if (ValidateUtil.isNullOrEmpty(email) || ! ValidateUtil.isEmailValid(email)) {
registrationErrors.add(ValidateErrors.EMAIL);
}

OR

you can fix your ValidateUtil.isEmailValid() to just cope up with the null email values. It will not crash but it will only return false.

OR

There is one more way to fix your issue.

It will work when you will throw away next line from your form:

enctype="multipart/form-data"

And you will pass all parameters at the request ok:

 <form action="/registrationform" method="post">
   <%-- error messages --%>
   <div class="form-group">
    <c:forEach items="${registrationError}" var="error">
    <p class="error">${error}</p>
     </c:forEach>
   </div>
9 7 4
38,600 points

Related questions

0 votes
1 answer 441 views
441 views
Problem : I am trying to display Data from DB.But facing error as followsthe server encountered an unexpected condition that prevented it from fulfilling the request.
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
1 answer 54 views
54 views
Problem : Hi I am trying to develop the web application its working fine but since yesterday I had the problem when I try to click the link it gives me below error The length of the query string for this request exceeds the configured maxQueryStringLength value. ... to auto generate I am trying to use asp dotnet4 Ajax control toolkit and also using the update panel. Any suggestions on this ?
asked Feb 2 jwilliam 3.9k points
0 votes
1 answer 48 views
48 views
Problem : I have my newly created website. First time I was able to succesfully login. The default address: www.abc.com I typed above address on browser and it redirected me to my login page: www.abc.com/pages/landingpage.aspx When I entered my login credential and tried to log ... open my site number of tabs and the browsers but as soon as I am logged in to my site, I am getting the above error.
asked Jan 31 jwilliam 3.9k points
0 votes
1 answer 12 views
12 views
Problem: I am a na&iuml;ve to Java, Jsp, Servlet and trying to make a very small registration program with the database. But while trying to run this I am facing below errors: HTTP Status 405 - HTTP method GET is not supported by this URL type Status report message HTTP ... </welcome-file>     </welcome-file-list> </web-app> I am looking for Java expert who can help me in fixing above error.
asked Jul 29 Raphael Pacheco 4.9k points
0 votes
1 answer 5 views
5 views
We are retrieving data from database and displaying it in table in a JSP however we don't have any idea about how to display it on text fields. Can anyone here help us with coding ?
asked Sep 26 Daniel Anderson 4k points