• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet & Javascript

 
Amardeep Salkar
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
 
Ankit Garg
Sheriff
Posts: 9519
22
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....

 
Bauke Scholtz
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic