• 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:

How to call JSP function through JavaScript

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody please tell me
How to call JSP function through JavaScript
i mean Javascript tag
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP/Java runs at the server machine. Javascript runs at the client machine.
So basically you need to fire a request to the server.

There are several ways to do it in Javascript.
1) A plain GET request using window.location.
2) A form submit using form.submit().
3) An asynchronous request using XmlHttpRequest object (Ajax).

Alternatively, if you just need a JSP/Java variable which is already available in the scope while rendering the HTML output, then you can also just let JSP print it out as a Javascript variable. E.g. var foo = '${foo}';

That said, the term "JSP function" makes me think that you wrote raw Java code as scriptlet in a JSP file. This is considered a bad practice. You should write Java code in Java classes. Use a Servlet class as port to the Java code.
 
Raul cool
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanxx.. .
I hope it will work ..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic