The name of param passed to request.getParameter() method is dynamic

Hi, I have a concern. Hope someone can help me, thanks!

The name of the drop down menu is generated dynamically

<select name="<c:out value="${id}"/>versions" >

<option>

......

</option>

</select>

where id is defined using

<c:set var="id" value="xxx"/>

I am just wondering how do I get the value of the param using request.getParameter()?

The ways

1. <% request.getParameter("<c:out value="${id}"/>versions") %>,

2. <% request.getParameter("<c:out value=\"${id}\"/>versions") %>,

3. <% request.getParameter("${id}versions") %>

wouldn't work. It would simply treat whatever in the quotes as strings. Are there other ways to do?

Thanks a lot!

[775 byte] By [tomtsui_tszkina] at [2007-11-27 10:56:46]
# 1

You cannot use JSTL inside scriptlets. Just handle it as local/page Java variable (only if it actually is):<% request.getParameter(id + "versions") %>

By the way, I recommend you to dump scriptlets and separate the business logic into a Servlet.

BalusCa at 2007-7-29 12:04:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi, can I ask you a question? I changed the code to:

<% request.getParameter(id + "versions") %>

but the compiler complaints, saying that

It cannot resolve symbol : variable id

Can you suggest me a better way to do?

Thanks

tomtsui_tszkina at 2007-7-29 12:04:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Actually this is what I was trying to do:

<select name="<c:out value="${id}"/>versions" >

...

<c:if test="${param.{id}versions == yyy}"> selected </c:if>

...

</select>

Do you know how to make the comparision works? The problem is the double curly bracket.

Thanks again

tomtsui_tszkina at 2007-7-29 12:04:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...