• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling servlet through hyperlink click

 
ali shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
i am calling my servlet through hyperlink, like on click event of hyperlink , i am calling submit of my form and in form i used action to call my servlet,but it did not work,
can any body tell me , what is wrong with this approach or is there any other approach to call a servlet through clicking on hyperlink
thanks
ali
 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, this could be caused by any number of things...
1. An incorrect URL in the action statement of your form
2. You could be using the wrong type (POST or GET) in your form
3. Your Servlet may not override the correct getXxx() method to match your form submission
4. Your web server may not be running or configured properly to accept the Servlet call

Review these possibilities and then if you still need help post some code for us to look at...
 
ali shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, but see as you mentioned, i checked all the possibilities, but still it did not work, can u please write the code fragment for calling a servlet by href clicking.
regards
ali
 
shai koren
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali
what do you mean doesnt work???
what error do you get
the basic syntax is
<a href="MyServlet?param1=value1&month=5&year=2002"> bla bla bla >/a>
have a look at your web.xml check that all information about the servlet is there.
<servlet>
<servlet-name>MyServlet</servlet-name>
<display-name>MyServlet</display-name>
<description>description </description>
<servlet-class>com.mycomp.project.servlets.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
that's just a guess of course because we dont even know what error you get.
cheers
shai
 
ali shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks shai, but because i am unable to embed my html code in this text area, i am unable to clerify my requirement. can you tell me how i can embed my html with this edit area.
ali
 
shai koren
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think you can just paste it in the edit box.
the html is disabled which is fine but still we could see what you tries to do.
more importantly what is the error you are getting?
 
Sunil K Bansal
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
u hv to call javascript funtion like this
<a href="javascript:void(formSubmit())">call servlet</a>
<script language=javascript>
function formSubmit()
{
document.form_name.submit();
}
</script>
Bansal
 
ali shah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks shai, bansal, let me try it, i will let you know the progress
regards
ali
 
Syed Zackriya Hussainy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ali shah:
hi there,
i am calling my servlet through hyperlink, like on click event of hyperlink , i am calling submit of my form and in form i used action to call my servlet,but it did not work,
can any body tell me , what is wrong with this approach or is there any other approach to call a servlet through clicking on hyperlink
thanks
ali
 
Syed Zackriya Hussainy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ali shah:
hi there,
i am calling my servlet through hyperlink, like on click event of hyperlink , i am calling submit of my form and in form i used action to call my servlet,but it did not work,
can any body tell me , what is wrong with this approach or is there any other approach to call a servlet through clicking on hyperlink
thanks
ali
 
Syed Zackriya Hussainy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ali shah:
hi there,
i am calling my servlet through hyperlink, like on click event of hyperlink , i am calling submit of my form and in form i used action to call my servlet,but it did not work,
can any body tell me , what is wrong with this approach or is there any other approach to call a servlet through clicking on hyperlink
thanks
ali

Just testing yaar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic