I have an issue...
which validates entered info from the JSP page with the database. Then I need it to change back to
the JSP page moving data to different form textboxes than originally they were in if needed,
reset focus, and display a message in an alert or in the html of the JSP.
I've tried using the dispatcher.forward method from my servlet forwarding to the url with parameters
attached and this works when returning to the page, but now when I initially go to the JSP page it
expects some parameters and error out with null exception. is there better way around this?
Correct me if I understood it wrong, you have a JSP ( lets say login.jsp) where a user inputs his username and password and then this information is validated via a call to another servlet ( lets call it ValidationServlet.java ), and then the result of validation is shown back to the login.jsp ?
I had come across a similar scenario, and we used Ajax via java script to achieve this.I can share you what I had done.
First of all , after user entered his information on the logn.jsp , I would send an ajax request to a ValidationServlet which would authenticate the users credentials and generate some HTML based on the validation criteria . Now ajax from jquery has a success method ( which is called when a successful ajax request has been returned ) and it takes a string input . we would populate the string with the generated HTML from the validationServlet and then disaplay it on the JSP. since it was an ajax request, we didnt have to worry about sending data back and forth between different pages.
I can also share you the jquery ajax method I used.
Regards, Muhammad Saif Asif Mirza
Joined: Mar 05, 2012
Thanks so much for your reply, but I think I might need to explain and show more code so
everyone will understand much better what i need help with.
here's what I've accomplished so far:
I've created a JSP file called Index.jsp which has three forms on it:
1.) new member sign up form
2.) current member sign in form
3.) I forgot my password form
At this point everything above works great. :-)
But now I need to go back to the Index.jsp page if there was a validation issue.
For example, if the user fills out and submits the New Member Join form and the data validation determines
the email address used is already in our database, I want to return to the index.jsp page and display the
users email address in the email address textbox of the "I forgot my password" form, and also display
an alert pop-up telling the user his email address already exists in our database please request sign-in information
and your current sign-in information will be emailed to you. followed by the email address textbox being in focus
and posibly highlighted.
What I tried and how it worked out:
I tried adding the following java to my validateNewMemberData servlet:
This did not seem to work, so I tried:
This seemed to work, but had a bad result on the intitial viewing of the Index.jsp page with a null exception because no parameter
would be captured in my index.jsp page's code:
Is there any other method or correction to what I'm attempting to do available?