Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Default using a link to call servlet

    i want to use a link to perform an action instead of using a button like this

    <form action="LoginServlet" method="post">
    <h5 align="center"><input type="submit" value="updateTeam"></h5></form> problem is my servlet direct the program by looking the value(updateTeam).

    how can i use a link..please help me i tried many ways....i tried using java script

    function update(){

    document.forms[0].action="LoginServlet";
    document.forms[0].submit();

    }
    </script>

    <body >

    <a href="javascript:update()" >view</a>
    but this is throwing one error...

  2. #2
    wolve634's Avatar
    wolve634 is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default

    easily :

    if you have named your servlet as myServlet,then you can call it from a link like this:
    <a href="myServlet">Call myServlet</a>
    that's it!!!!!!!!!! recall you name a servlet in web.xml file !

  3. #3
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    7

    Default

    Just correcting some code wolve634's answer for me is more efficient than this. I just want to fix this code ^_^ Just keep everything organize and put the TAGS in the rigth position. Html tags is position sensitive ^_^

    Java Code:
    <body>
    
    <form name = "Test" action="LoginServlet" method="post">
    <script  type="text/javascript">
    function update(){
    Test.submit();}
    </script>
    <a href="javascript:update()" >view</a>
    </form>
    Mind only knows what lies near the heart, it alone sees the depth of the soul.

  4. #4
    Md Saim is offline Member
    Join Date
    Sep 2008
    Location
    Kolkata, India
    Posts
    20
    Rep Power
    0

    Default

    use the bellow link

    <a href="#" onclick="javascript:document.forms[0].submit();return false;">updateTeam</a>

Similar Threads

  1. JSP - Link tcreate Folder (servlet)
    By roseline43 in forum Java Servlet
    Replies: 0
    Last Post: 09-15-2008, 01:27 PM
  2. how can we call Logout servlet by closing window
    By nagesh1811 in forum Java Servlet
    Replies: 2
    Last Post: 07-11-2008, 08:41 AM
  3. Link for 64 bit JDK.
    By aparna in forum New To Java
    Replies: 0
    Last Post: 03-19-2008, 03:15 PM
  4. Replies: 1
    Last Post: 08-07-2007, 04:47 PM
  5. How to call JSP inside Servlet
    By Swamipsn in forum Advanced Java
    Replies: 0
    Last Post: 07-31-2007, 01:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •