• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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.
 
Marshal
Posts: 67197
169
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
Marshal
Posts: 67197
169
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
Marshal
Posts: 67197
169
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
Marshal
Posts: 67197
169
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 ]
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!