This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Calling servlet from JavaScript  RSS feed

 
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.
 
Author and ninkuma
Marshal
Posts: 66806
168
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?
 
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
Posts: 66806
168
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
Posts: 66806
168
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
Posts: 66806
168
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!