• 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

calling a servlet from javascript function??

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can i call a servlet from inside a javascript function??
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can very well call a servlet from a javascript function.
document.location.href=/ServletName?param1=value1&param2=value2..
This line of code causes the servlet to be called using get method.
If the servlet needs to invoked using post method
You can set the forms action to the servlet to be called and method to POST and in the javascript function just you can say
document.<formname>.submit();
I hope this helps
Regards
Vels
[This message has been edited by Vels Manian (edited July 01, 2001).]
 
deep venu
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vels,
thanx..
i was aware of the submit function ..what i actually was trying out was that i need to pop up a window on a particular value getting selected from a list box..
I used to do this using window.open property..can i pass the URL of a servlet instead of a normal html page ??
 
Vels Manian
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Ofcourse, u can pass a URL of a servlet in the window.open().
If u want to call the servlet using POST method. U can set the target of the form to the window name and submit the form.
For ex:
<SCRIPT>
function onClickSubmit()
{
window.open("mywindow");
document.<frmname>.submit();
}
</script>
<body>
<form name="frmmain" action="/Servlet" target="mywindow" method="POST">
..
</form>
</body>
</html>
Try this out.
Vels
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic