aspose file tools*
The moose likes Servlets and the fly likes calling javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling javascript function " Watch "calling javascript function " New topic
Author

calling javascript function

kishore kovil
Greenhorn

Joined: Dec 21, 2006
Posts: 20
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
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I would like to suggest Commons Validator - Validator for both javascript/client-side validation as well as server-side.
rajesh ssh
Greenhorn

Joined: Aug 23, 2006
Posts: 11
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...


Regards<br />RAJESH.M
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: calling javascript function
 
Similar Threads
Servlet with Javascript
Calling a Servlet (Urgent)
Href with onClick
calling a servlet from javascript function??
JOptionPane No X11 DISPLAY error