• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling servlet through javascript

 
jyoti mahajan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4324
236
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jyoti mahajan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL must begin with the context path of the application.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64716
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic