• 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

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: 9613
37
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.
 
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
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!