aspose file tools*
The moose likes Servlets and the fly likes calling servlet through hyperlink click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling servlet through hyperlink click" Watch "calling servlet through hyperlink click" New topic
Author

calling servlet through hyperlink click

ali shah
Greenhorn

Joined: Jun 14, 2002
Posts: 6
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

Joined: Mar 23, 2001
Posts: 301
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...


Wait a minute, I'm trying to think of something clever to say...<p>Joel
ali shah
Greenhorn

Joined: Jun 14, 2002
Posts: 6
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

Joined: Nov 04, 2001
Posts: 48
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


Shai koren<br />SCJP2 <br />SCEA (well yea only part 1 so far)
ali shah
Greenhorn

Joined: Jun 14, 2002
Posts: 6
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

Joined: Nov 04, 2001
Posts: 48
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

Joined: Jan 04, 2001
Posts: 62
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

Joined: Jun 14, 2002
Posts: 6
thanks shai, bansal, let me try it, i will let you know the progress
regards
ali
Syed Zackriya Hussainy
Ranch Hand

Joined: Jun 24, 2002
Posts: 30
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

Joined: Jun 24, 2002
Posts: 30
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

Joined: Jun 24, 2002
Posts: 30
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling servlet through hyperlink click