0

I have found myself requiring to send some forms automatically in a few key areas of my program to go from one jsp to another using the action attribute. The problem is things such as <jsp:forward> do not seem to work as it does not have an "action" attribute, and I can only provide it with a specific page, rather than what I am doing with the action attribute in the form.

In doing so, I have ended up with many of my jsp pages ending like the following:

<form name="my_form" action="../some_id" method=post>
</form>        
<script>
    document.my_form.submit(); //automatically submits the form
</script>

My problem lies with trying to move away from using javascript.

Essentially, I need an alternate way to run the "action" from the form, as you can see I am not actually using the form to pass any parameters at all.

Any suggestions would be greatly appreciated. Let me know if I need to provide any additional information or clarification and I will try to reply as soon as I can.

TheOneWhoPrograms
  • 629
  • 1
  • 8
  • 19
  • Fairly similar question to [this](http://stackoverflow.com/questions/10175945/submit-form-using-only-php-without-javascript). You can't submit a form from the client side without the client the requesting it. You can only use a JavaScript or create a button and have the end-user press it. – Pete Jul 02 '14 at 14:14
  • 1
    If you're using a server-side resource that requires a POST, you're out of luck. If you are using a GET, you could use a meta-refresh tag to redirect as if the user had submitted, but you'll have to either use a hardcoded URL or use your JSP to prepopulate the query parameters. – Palpatim Jul 02 '14 at 14:20

0 Answers0