This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes calling servlet through javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling servlet through javascript" Watch "calling servlet through javascript" New topic
Author

calling servlet through javascript

jyoti mahajan
Greenhorn

Joined: Nov 18, 2010
Posts: 27
i want to call my servlet using javascript.

code is:

function check1()
{
document.emp.action="/emp_mst";
document.emp.submit();
}

my servlet is in the follwing folder:

sa.com.emp_mst

if i put the full path it said emp_mst doesn't found....

how i put the path in action.
please reply soon.
regards
jyoti
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3057
    
  38

Welcome to JavaRanch, Jyoti.
What did you mean by the 'path'? Have you used some servlet mapping on web.xml ?

Please UseCodeTags when you post a source code.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
jyoti mahajan
Greenhorn

Joined: Nov 18, 2010
Posts: 27
yes.....
<servlet>
<servlet-name>emp_mst</servlet-name>
<servlet-class>cdac.controller.emp_mst</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>emp_mst</servlet-name>
<url-pattern>/emp_mst</url-pattern>
</servlet-mapping>

this is the web.xml mapping of servlet.
yes i am talking abt the path.
jyoti mahajan
Greenhorn

Joined: Nov 18, 2010
Posts: 27
path means what I have to write
<form method="POST" name="emp" id="frm1" action="/emp_mst" >

in the action="/emp_mst"...the exact path wht i have to write.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61071
    
  66

The URL must begin with the context path of the application.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61071
    
  66

And, as already asked, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: calling servlet through javascript