akhila vaddi
akhila vaddi

Reputation: 1

javaservlet page

Can I submit a jsp form without using submit button but with a link? if possible how ? Please let me know as soon as possible. I am stuck with my project.

Upvotes: 0

Views: 50

Answers (4)

Jason
Jason

Reputation: 937

Have a look at this link: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml

You can use javascript to submit a form with:

document.forms["myform"].submit();

Upvotes: 0

fforw
fforw

Reputation: 5491

Only submit buttons can really submit the form on their own.

Forms can only be submitted by links if the links have an javascript onclick event that submits the form. Another option is to use a special class attribute on the submit button to make it look like a link with CSS.

Upvotes: 0

CoolBeans
CoolBeans

Reputation: 20800

Sure ... you can do something like below:-

<form id="test" action="something">
    <a href="javascript: submitform()">Submit Form</a>
    </form>
    <script type="text/javascript">
    function submitform()
    {
      document.getElementById('test').submit();
    }
   </script>

Upvotes: 1

BalusC
BalusC

Reputation: 1108537

Certainly you can. Just let the link URL point to an URL matching the servlet's <url-pattern> and then do the job in doGet() method of the servlet.

See also:

Upvotes: 0

Related Questions