Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling servlet from JavaScript

 
Mam Kat
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a jsp page. When i click on a button in the page, I want to call servlet class and submit the form in javascript. I can't give form action as servlet class. Can someone help me with this.

thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not clearly stated what your issue is. All you need to do is to set the action of the form to the appropriate URL for the servlet. Is that where you are having difficulty?
 
sudhir kamath
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mam Kat:
Hi,

I have a jsp page. When i click on a button in the page, I want to call servlet class and submit the form in javascript. I can't give form action as servlet class. Can someone help me with this.

thanks in advance.


hi,

function bustOut(){
var newWin = window.open("the real url", "subWindow","height=500,width=700,resizable=yes,scrollbars=yes");
}

call this fuction inside a javascript.

HTH,
sundeep kamath
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why on earth would he want to open a new window?
 
Mam Kat
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't give the form action as URL. I am initially submitting the form on change of a radio button so the form action is given as the same page. (if the selected value of radio button is Yes user is asked to enter one set of values, if it is no another set and these values are used in servlet class)

I want to get the request paramters in the servlet class. So i have to submit the form and invoke the servlet. i am thinking to do this with a button onClick event. How can i do this? is there a better way than what i am thinking?
thanks for the help.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your onclick handler. set the form action to the URL of the servlet and submit the form.
[ October 25, 2005: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic