Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I access a textfield value using JSTL?

Posted on 2011-03-09
2
Medium Priority
?
1,842 Views
Last Modified: 2013-11-24
Hi,

I have a jsp page which has JSTL code in it. I have a list of checkboxes with naming goes as chkbox1, chkbox2, chkbox3....

So on select of chkbox a corresponding fields with naming convention textfield1, select1 values has to be inserted into an arraylist.

What I have done so far is creating the textfield1 using the attached code.

What I need to know is :
  - how can we get the value of the [textfield, select] using jstl tag?
  - how can we create a arraylist in jstl?
  - how can a jstl send the arraylist to the action/model?

I have also attached a image of what the form will look like... So when I select the checkbox... The corresponding Label1 value, The select box value and the text field value has to be selected.

can you please provide a solution for my problem.

Thanks in advance
<c:forEach var="i" begin="1" end="9" step="1" varStatus ="status">
<c:set var="tdAttribute" value="tdAttribute${i}"></c:set>
<c:out value="${tdAttribute}" /> 
<c:out value="${param.tdAttribute}" />
</c:forEach>

Open in new window

preview.jpg
0
Comment
Question by:JeraldFernando
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
rrz earned 1500 total points
ID: 35085207
> - how can we get the value of the [textfield, select] using jstl tag?
If the JSP with the JSTL tag receives a request with the request parameters in it then you can use
${param.yourTextfieldName}  
and
<c:forEach var="current" items="${paramValues.yourSelectName}" >
      ${current}
</c:forEach>
to display the data.  

> - how can we create a arraylist in jstl?
You can not create an ArrayList using JSTL. JSTL is used to display your data.
You could create one in a scriptlet.

> - how can a jstl send the arraylist to the action/model?  
It could set the ArrayList (or the String[] that is in param) into session-scope. Afterwards it would be available.    

It would easier to take things one step at a time. For example here is a JSP that demonstrates the displaying of multiple values from a select. It just send the request to its self. Please just copy and paste.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<form>
<select name="selectTest" multiple="multiple">
           <option value="one">one</option>
           <option value="two">two</option>
           <option value="three">three</option> 
           <option value="four">four</option> 
</select>
<input type="submit"/>
</form>
<c:forEach var="current" items="${paramValues.selectTest}" >
      ${current}
</c:forEach>
</body>
</html>

Open in new window














 
0
 

Author Closing Comment

by:JeraldFernando
ID: 35339129
Patrially helped me in acheiving what I need
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
A solution for Fortify Path Manipulation.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question