• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

form data accepted by JSP page

Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an issue...
I've got a sign-in JSP page with three forms which has javascript that calls a validation servlet page
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?

Thanks, Joe
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Joe McTigue ,

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.
Joe McTigue
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saif,

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

My forms are submitted through an form button OnClick event using plain old javascript (no ajax) which brings up one of three valiadationServlets:
1.) validateNewMemberData
2.) validateCurrentMemberdata
3.) validateEmailPassword

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:

Then handle filling the textbox with a javascript triggered in the Index.jsp pages's body tag's onload event.
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?

Thanks in advance for any guidiness on this.
money grubbing section goes here:
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic