• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Servlet & Javascript  RSS feed

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

Please let me know How to call servlet class through javascript

what I'm doing ?
In jsp page onclick event I've to call MyServlet.java..


It is not working ?

Regards,
Amardeep
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all you need to give us the source of your web.xml which defines the mapping of this servlet. then you need to give us the url from which you are accessing the page where the javascript code is. Thirdly you should try this code

 
Amardeep Salkar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ankit Garg wrote:First of all you need to give us the source of your web.xml which defines the mapping of this servlet. then you need to give us the url from which you are accessing the page where the javascript code is. Thirdly you should try this code




here is web.xml code

here I've to call ProjectMaster from javascript....

 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ankit Garg wrote:First of all you need to give us the source of your web.xml which defines the mapping of this servlet. then you need to give us the url from which you are accessing the page where the javascript code is. Thirdly you should try this code


This is invalid Javascript either (although it works in *some* browsers).
Use window.location.href.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Amardeep Salkar wrote:


You haven't definied those servlets at all. The <servlet> entries are missing.
 
Marshal
Posts: 67254
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And use server-relative URLs rather than page-relative URLs. Notation such as "../" should never be used in web apps. All your URLs should being with the context path.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!