• 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
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

calling javascript function

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I wanted to call a javascript function to validate login page from a servlet.
or I want to display an error message in servlet itself
is that possible?
Please help
bye
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't use JavaScript to validate in the servlet - JS is executed in the browser, while servlets run in the server. Thus the two can't be mixed.
 
Sheriff
Posts: 67762
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
Remember that servlets and JSP are just server-side mechanisms to send HTML (and Javascript) to the browser. So you can easily inlcude any Javascript you like in the output you generate. Be aware that the Javascript executes on the client, not the server.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to suggest Commons Validator - Validator for both javascript/client-side validation as well as server-side.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ... in what way you want to display error message in the servlet...i mean if something happns then this error message has to populate...so like that ..what type??...you can do like.... response.getWriter().println("<h3 > error message </h3>"); like this whn calling this servlet it wil show you on browser... could you tell clearly..how the error message has to come...
 
reply
    Bookmark Topic Watch Topic
  • New Topic