Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jstl tag  RSS feed

 
kittu basant
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Within a for each tag, i have a text box created dynamically till the end of for each tag,Now i want to get the values of the text box from jsp to servlet . but i would like to know how to request.getparameter().
I tried puting the
<c:forEach var="row" tems="${sessionScope.listOfBeans}">
type="text" name="license"+"${row}" value=" ${row.team_ph}"
</c:forEach>

but the row value i random and would not be able to get the exact value in servlet ie request.getparameter(???).
Any alternative for this... a sample example would be appreciated

regards,
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about using request.getParameterNames() first to get an Enumeration of all the parameter names? Then use those names with request.getParameter().
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSTL specification is a great resource.

The JspFaq has a link to the SpecificationUrls.

Not sure what version of JSTL you are using, but I took a quick look at the JSTL 1.1 specification and found this:

It is also possible to access HTTP request parameters
via the implicit objects param and paramValues. param is a Map object where
param["foo"] returns the first string value associated with request parameter foo,
while paramValues["foo"] returns an array of all string values associated with that request parameter.
The code below displays all request parameters along with all their associated
values.






You should really download the specification. In case I made an error re-formatting the information from the spec, please take a look at the actual example code in the spec.
[ June 07, 2008: Message edited by: Carol Enderlin ]
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kittu,

You need not change the name of the text box dynamically, you can have it as static like,



In servlet if there are multiple values for a request parameter (in this case 'license'), it will be returned to you as an array. Hence you can get it like,



Hope this helps.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!