• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

checking username and password with database using JSP and jQuery.

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I created a login page in HTML and I created a servlet and when I submit the form it will go to the search servlet and display the user details if the username and password are correct or it will go to new page and display the error page.

But, now I want to display the error message on the login form itself if the username or password incorrect. How can I connect these two pages and display the error message if the login details are incorrect or it should display the user details if the login details are correct.
I want to display an error message instead of redirecting to the new page when the username or password incorrect. For that I am using jQuery.

Thank You.
Here is my code.

Login.html



SearchServlet
URL : search



 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing that you are doing wrong is putting Java code in a JSP. That code should be in a servlet. JSPs are for views only. Using them to process the submission is an egregious abuse of the technology.

Move the code to a servlet as your first step.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see you went ahead and edited your post after I answered. Please don't do that. Make new posts with updated code. Replacing the original post after I replied made my replies look like nonsense.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When your code has been refactored, please post it as a new reply and let us know what problems you are having with it.
 
kumar sapan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:When your code has been refactored, please post it as a new reply and let us know what problems you are having with it.





I created HTML page and servlet for login page and to display the user details. In that servlet, a new error page will be displayed if the username or password are wrong.
Now, I am trying to display the error message on the same login page if the user details are wrong by adding jQuery to it. In servlet I am doing the comparison with database
but I don't have any idea how to connect the jQuery to the servlet.

here is my code...




 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kumar sapan wrote:but I don't have any idea how to connect the jQuery to the servlet.


The Ajax URL should be the mapping for the servlet. Be sure to start the URL with the context path.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic