• 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

Simple ajax question

 
Ranch Hand
Posts: 34
Netbeans IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to learn how to tell the succes and error events in ajax to show messages according to a java value.
My boolean value will tell me if the user is ok to login or not.This is my server side loginForm.jsp


This is my javascript function


Any help would be apreciated.I really need to understand how succes and error work and the most secure way to do such login actions.
 
Sheriff
Posts: 67746
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 really can't tell what you are trying to accomplish, but there should not be any Java scriptlets in modern JSP pages.

In any case, Ajax cannot interact with any Java that you do put in the JSP. What are you actually trying to accomplish?
 
Stamin Adrian
Ranch Hand
Posts: 34
Netbeans IDE Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does succes and error work? I want to show a message only when the boolean is true or false.It seems succes is called whenever the data gets there corectly.But I want more than that.I want to show a succes message when I am 100% positive that the server-side code worked.Is succes and error reliable?What if the data gets on my jsp page, but it fails to make the controller call corectly.It will still point out to the user that the action was succesfull.I know modern jsp pages don't have scriptlets on.In the future I will try it that way.I only use managed beans on the pages.I have different beans for the view.It's still MVC.
 
Bear Bibeault
Sheriff
Posts: 67746
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
The error or success of the request is available as the status code of the response. The server-side operation needs to set the status code correctly.

You don't need Java at all for any of this. All Ajax-y stuff can happen using JavaScript.
 
reply
    Bookmark Topic Watch Topic
  • New Topic