tiamat
tiamat

Reputation: 971

JSP send parameter to servlet in form action field

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 !

Upvotes: 0

Views: 3972

Answers (3)

Gerassimos Barlas
Gerassimos Barlas

Reputation: 11

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.

Upvotes: 0

langeles86
langeles86

Reputation: 162

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.

Upvotes: 0

tiamat
tiamat

Reputation: 971

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 !

Upvotes: 1

Related Questions