aspose file tools*
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
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: 3216
    
  49

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: 61646
    
  67

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: 61646
    
  67

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.
 
jQuery in Action, 2nd edition
 
subject: calling servlet through javascript