0

I encounter a problem while sending a parameter to a Servlet.

My JSP page is retrieving information from a previous servlet displayed like this (${owner)/${numero}):

<div class="control-group">
                            <label class="control-label">${numero}</label>
                            <div class="controls">
                              <span id="user" class="input-xlarge uneditable-input">${owner}</span>
                            </div>
                          </div>

but this page is also including a form to forward some params to another Servlet like this:

<form class="form-horizontal" action="/webUpdateStatus?id=${numero}" >

unfortunately the tag ${numero} (correctly displayed in another field) is not displayed in the tag action...any tips to get it displayed and passed to my Servlet ?

Thanks !

tiamat
  • 879
  • 2
  • 12
  • 35
  • What do you mean by "not displayed in the tag action"? – Angelo Oparah May 03 '16 at 22:47
  • when I submit my form to the servlet, the link is not containing the value of my number String, there is only /webUpdateStatus?id= sent without the field (sorry it was not so clear) – tiamat May 03 '16 at 23:10

3 Answers3

1

finally I found a solution...

if you want to pass a parameter in the form action, you have a workaround by using a input hidden field:

<input type='hidden' name='numero' id='numero' value="${numero}" />

I didn't found a solution to integrate dynamic content to the action form but it remains the same !

tiamat
  • 879
  • 2
  • 12
  • 35
  • found an answer related to your question: http://stackoverflow.com/questions/732371/what-happens-if-the-action-field-in-a-form-has-parameters. Apparently the query string in the action field is dropped. – Angelo Oparah May 04 '16 at 07:29
0

You can't do such kind of code in any form, does not matter what language or framework.

If you want to use a form is mandatory to use inputs, you can't put the values in url like that. For these case must use hidden input.

If you want to do so you won't use a form and simply a url with all parameters sticked together, in the action side it will be a method with the same name of url and with the same parameters you bind in.

For MVC use always a model, is better pratice instead of getting values from request.

langeles86
  • 162
  • 1
  • 12
0

There is also another way: create a separate with hidden inputs for every page you would like to call. For example, this would work if you have a table and each row is supposed to have a button that leads to a page with different parameter values.