<c:if > problem with param

Hi everyone!

I have problem that i need to resolve.

I had next code:

<form action="Pretraga.jsp" method="POST">

<tr valign="top" height="19">

<td width="145" bgcolor="#ffff66"><font face="Arial" size="2">

<div>Po vrsti zahteva</div></font>

</td>

<td width="383"><input size="6" name="rednibroj">牋牋牋牋牋牋牋牋牋牋牋牋?

?<input type="submit" name="method1" size="10" value="Pretrazi">

</td>

</tr>

</form>

<form action="Pretraga.jsp" method="POST">

<tr valign="top" height="14">

<td width="568" bgcolor="#ffff66"><font face="Arial" size="2">

<div>Po broju predmeta</div></font>

</td>

<td width="383"><input maxlength="2" size="2" name="referent">牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋牋?

<input type="submit" name="method2" size="10" value="Pretrazi">

</td>

</tr>

......

How i can put in the code down here name of input method1 and method2? I want when is submited input with name method1 then to execute code like this

<c:if test="${what_i_ need_ to _put_ here'}">

some code

</c:if>

and if is submited input with name mehod2 to executed code

<c:if test="${what_i_ need_ to _put_ here}">

some othet code

</c:if>

I assume that is something like this

<c:if test="${param(name)=='method1'}">

some code

</c:if>

but i need help

Thanks

[1625 byte] By [boske3a] at [2007-10-2 20:32:08]
# 1

Ok let me simplify this.

I have this input form:

....

<form action="Pretraga.jsp" method="POST">

...

<input size="6" name="rednibroj">

<input type="submit" name="method1" size="10" value="Pretrazi">

...

</form>

and i want to check if name=="method1" and then do something.

How i can write it in JSTL code ? Is this code below good?

.....

<c:if test="${param.name=='method1'}">

do something

</c:if>

....

Can anyone help me in this simply problem?

Thanks

boske3a at 2007-7-13 23:15:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

When you click on a submit button, it sends the name value pair of that button.

So if you click the first, it sends "method1=Pretrazi" if you click the second it will send "method2=Pretrazi"

It will only ever send one of these - the one related to the button you clicked.

So you only have to look for the presence/lack of the parameter related to the button for this code

<c:if test="${ not empty param.method1 }">

You clicked the first button.

</c:if>

<c:if test="${ not empty param.method2 }">

You clicked the second button.

</c:if>

You could do this with <c:if>/<c:when> or with a <c:choose>/<c:when> combination.

evnafetsa at 2007-7-13 23:15:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...