wood burning stoves 2.0*
The moose likes Servlets and the fly likes Servlet & Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet & Javascript" Watch "Servlet & Javascript" New topic
Author

Servlet & Javascript

Amardeep Salkar
Ranch Hand

Joined: May 22, 2008
Posts: 46
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

Joined: Aug 03, 2008
Posts: 9291
    
  17

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



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Amardeep Salkar
Ranch Hand

Joined: May 22, 2008
Posts: 46
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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Oct 08, 2006
Posts: 2458
Amardeep Salkar wrote:

You haven't definied those servlets at all. The <servlet> entries are missing.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet & Javascript
 
Similar Threads
how to call servlet from javascript without using form
calling a servlet from a javascript
Ajax and Servlets
JOptionPane No X11 DISPLAY error
calling a servlet from javascript function??