C:for:each not getting the values if a pass a parameter to the List method
I have a java class where i have a method and that method is taking some parameter like
below is my java code which has a getoutlet method
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
if i put system.out.print it gives me the list [jayanagar,malleshwaram,kolar,ol1]
but it is throwing an error while called from the UI (jsp) using c:for:each
i am passing idDB as a parameter
now in a list i am getting like this
[jayanagar,malleshwaram,kolar,ol1]
now i am calling this method by c:for:each in my jsp to populate this in a select option but the problem is it is throwing error
like my c:for:each code is
<jsp:useBean id="obj" class="com.touchpoint.Dao.Outlet" scope="page" />
<select id="all" name="outlet">
<option>ALL</option>
<c:forEach var="item" items="$obj.outlet">
<option>$item</option>
</c:forEach>
</select>
if iam not passing any parameter to my getoutlet method then its working fine but now i have to pass some parameter as per requirnment,The error it is showing is '$obj.outlet' Property 'outlet' not found on type com.touchpoint.Dao.Outlet Outlet is my java class name
so anyone out there please help me out
this is my java class
public class Outlet
Connection con = null;
Statement statement = null;
ResultSet resultSet = null;
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
// String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
String sqlOutlet="select * from ecustomer')";
/*System.out.println(idDB);*/
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
it is returning me [jayanagar,malleshwaram,kolar]
now i want to show this list in my select option dropdown
java jstl
add a comment |
I have a java class where i have a method and that method is taking some parameter like
below is my java code which has a getoutlet method
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
if i put system.out.print it gives me the list [jayanagar,malleshwaram,kolar,ol1]
but it is throwing an error while called from the UI (jsp) using c:for:each
i am passing idDB as a parameter
now in a list i am getting like this
[jayanagar,malleshwaram,kolar,ol1]
now i am calling this method by c:for:each in my jsp to populate this in a select option but the problem is it is throwing error
like my c:for:each code is
<jsp:useBean id="obj" class="com.touchpoint.Dao.Outlet" scope="page" />
<select id="all" name="outlet">
<option>ALL</option>
<c:forEach var="item" items="$obj.outlet">
<option>$item</option>
</c:forEach>
</select>
if iam not passing any parameter to my getoutlet method then its working fine but now i have to pass some parameter as per requirnment,The error it is showing is '$obj.outlet' Property 'outlet' not found on type com.touchpoint.Dao.Outlet Outlet is my java class name
so anyone out there please help me out
this is my java class
public class Outlet
Connection con = null;
Statement statement = null;
ResultSet resultSet = null;
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
// String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
String sqlOutlet="select * from ecustomer')";
/*System.out.println(idDB);*/
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
it is returning me [jayanagar,malleshwaram,kolar]
now i want to show this list in my select option dropdown
java jstl
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
Yes, but one can try some work around. Are you allowed to change some code in thecom.touchpoint.Dao.Outlet
Java class?
– prasad_
Nov 15 '18 at 9:50
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56
add a comment |
I have a java class where i have a method and that method is taking some parameter like
below is my java code which has a getoutlet method
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
if i put system.out.print it gives me the list [jayanagar,malleshwaram,kolar,ol1]
but it is throwing an error while called from the UI (jsp) using c:for:each
i am passing idDB as a parameter
now in a list i am getting like this
[jayanagar,malleshwaram,kolar,ol1]
now i am calling this method by c:for:each in my jsp to populate this in a select option but the problem is it is throwing error
like my c:for:each code is
<jsp:useBean id="obj" class="com.touchpoint.Dao.Outlet" scope="page" />
<select id="all" name="outlet">
<option>ALL</option>
<c:forEach var="item" items="$obj.outlet">
<option>$item</option>
</c:forEach>
</select>
if iam not passing any parameter to my getoutlet method then its working fine but now i have to pass some parameter as per requirnment,The error it is showing is '$obj.outlet' Property 'outlet' not found on type com.touchpoint.Dao.Outlet Outlet is my java class name
so anyone out there please help me out
this is my java class
public class Outlet
Connection con = null;
Statement statement = null;
ResultSet resultSet = null;
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
// String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
String sqlOutlet="select * from ecustomer')";
/*System.out.println(idDB);*/
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
it is returning me [jayanagar,malleshwaram,kolar]
now i want to show this list in my select option dropdown
java jstl
I have a java class where i have a method and that method is taking some parameter like
below is my java code which has a getoutlet method
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
if i put system.out.print it gives me the list [jayanagar,malleshwaram,kolar,ol1]
but it is throwing an error while called from the UI (jsp) using c:for:each
i am passing idDB as a parameter
now in a list i am getting like this
[jayanagar,malleshwaram,kolar,ol1]
now i am calling this method by c:for:each in my jsp to populate this in a select option but the problem is it is throwing error
like my c:for:each code is
<jsp:useBean id="obj" class="com.touchpoint.Dao.Outlet" scope="page" />
<select id="all" name="outlet">
<option>ALL</option>
<c:forEach var="item" items="$obj.outlet">
<option>$item</option>
</c:forEach>
</select>
if iam not passing any parameter to my getoutlet method then its working fine but now i have to pass some parameter as per requirnment,The error it is showing is '$obj.outlet' Property 'outlet' not found on type com.touchpoint.Dao.Outlet Outlet is my java class name
so anyone out there please help me out
this is my java class
public class Outlet
Connection con = null;
Statement statement = null;
ResultSet resultSet = null;
public List<String> getoutlet(String idDB) throws ClassNotFoundException, SQLException
List<String> list = new ArrayList<String>();
con = DBConnection.createConnection();
statement = con.createStatement();
// String sqlOutlet="select CUSTOMERDESCRIPTOR from ecustomer where CUSTOMERIDENTIFIER in(select CUSTOMERIDENTIFIER from mt_distributrol where mt_distributr_vcdistributrcode = '"+idDB+"')";
String sqlOutlet="select * from ecustomer')";
/*System.out.println(idDB);*/
try
ResultSet resultSet = statement.executeQuery(sqlOutlet);
while (resultSet.next())
list.add(resultSet.getString("CUSTOMERDESCRIPTOR"));
catch (SQLException e)
e.printStackTrace();
return list;
it is returning me [jayanagar,malleshwaram,kolar]
now i want to show this list in my select option dropdown
java jstl
java jstl
edited Nov 15 '18 at 10:24
asked Nov 15 '18 at 6:54
user10561216
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
Yes, but one can try some work around. Are you allowed to change some code in thecom.touchpoint.Dao.Outlet
Java class?
– prasad_
Nov 15 '18 at 9:50
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56
add a comment |
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
Yes, but one can try some work around. Are you allowed to change some code in thecom.touchpoint.Dao.Outlet
Java class?
– prasad_
Nov 15 '18 at 9:50
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
Yes, but one can try some work around. Are you allowed to change some code in the
com.touchpoint.Dao.Outlet
Java class?– prasad_
Nov 15 '18 at 9:50
Yes, but one can try some work around. Are you allowed to change some code in the
com.touchpoint.Dao.Outlet
Java class?– prasad_
Nov 15 '18 at 9:50
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56
add a comment |
1 Answer
1
active
oldest
votes
Here is an approach (a work around).
The Bean Class:
public class MyBean
private String paramInfo;
public void setParamInfo(String p)
paramInfo = p;
public String getParamInfo()
return paramInfo;
public List<String> getStuff(String param)
param = paramInfo; // substitute the value here
List <String> list1 = Arrays.asList("A", "B", "C");
List<String> list2 = new ArrayList<>();
list2.addAll(list1);
list2.add(param); // use the param value here
return list2;
NOTE: I have not changed the signature of the method getStuff(String param)
; this still accepts a String
parameter. I have added a new bean property which is a substitute for the parameter value. Note the usage of the bean's new property value paramInfo
.
The JSP Page:
<BODY>
<h2>Testing JSP</h2>
<jsp:useBean id="obj1" class="app.MyBean" scope="page" />
<c:set var="param1" value="Z"/>
<jsp:setProperty name="obj1" property="paramInfo" value="$param1" />
<c:set var="list1" value="$obj1.getStuff('')"/>
<c:forEach var="item" items="$list1">
<br/>ITEM: $item
</c:forEach>
<br><br>
<select name="list">
<c:forEach items="$list1" var="item">
<option value="$item"><c:out value="$item" /></option>
</c:forEach>
</select>
</BODY>
NOTE: The bean's method signature still remains same. The value passed to the method is a blank String
. The tag <jsp:setProperty ...
actually sets the parameter value.
This way you get to use the parameter value in the paramInfo
property within the getStuff
method.
The Result:
ITEM: A
ITEM: B
ITEM: C
ITEM: Z
NOTE: One can change the doStuff
method in the bean class not to accept the parameter, with this approach of setting the parameter separately.
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,getoutlet(String idDB)
need to begetOutlet(String idDB)
.
– prasad_
Nov 15 '18 at 10:32
|
show 7 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313923%2fcforeach-not-getting-the-values-if-a-pass-a-parameter-to-the-list-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is an approach (a work around).
The Bean Class:
public class MyBean
private String paramInfo;
public void setParamInfo(String p)
paramInfo = p;
public String getParamInfo()
return paramInfo;
public List<String> getStuff(String param)
param = paramInfo; // substitute the value here
List <String> list1 = Arrays.asList("A", "B", "C");
List<String> list2 = new ArrayList<>();
list2.addAll(list1);
list2.add(param); // use the param value here
return list2;
NOTE: I have not changed the signature of the method getStuff(String param)
; this still accepts a String
parameter. I have added a new bean property which is a substitute for the parameter value. Note the usage of the bean's new property value paramInfo
.
The JSP Page:
<BODY>
<h2>Testing JSP</h2>
<jsp:useBean id="obj1" class="app.MyBean" scope="page" />
<c:set var="param1" value="Z"/>
<jsp:setProperty name="obj1" property="paramInfo" value="$param1" />
<c:set var="list1" value="$obj1.getStuff('')"/>
<c:forEach var="item" items="$list1">
<br/>ITEM: $item
</c:forEach>
<br><br>
<select name="list">
<c:forEach items="$list1" var="item">
<option value="$item"><c:out value="$item" /></option>
</c:forEach>
</select>
</BODY>
NOTE: The bean's method signature still remains same. The value passed to the method is a blank String
. The tag <jsp:setProperty ...
actually sets the parameter value.
This way you get to use the parameter value in the paramInfo
property within the getStuff
method.
The Result:
ITEM: A
ITEM: B
ITEM: C
ITEM: Z
NOTE: One can change the doStuff
method in the bean class not to accept the parameter, with this approach of setting the parameter separately.
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,getoutlet(String idDB)
need to begetOutlet(String idDB)
.
– prasad_
Nov 15 '18 at 10:32
|
show 7 more comments
Here is an approach (a work around).
The Bean Class:
public class MyBean
private String paramInfo;
public void setParamInfo(String p)
paramInfo = p;
public String getParamInfo()
return paramInfo;
public List<String> getStuff(String param)
param = paramInfo; // substitute the value here
List <String> list1 = Arrays.asList("A", "B", "C");
List<String> list2 = new ArrayList<>();
list2.addAll(list1);
list2.add(param); // use the param value here
return list2;
NOTE: I have not changed the signature of the method getStuff(String param)
; this still accepts a String
parameter. I have added a new bean property which is a substitute for the parameter value. Note the usage of the bean's new property value paramInfo
.
The JSP Page:
<BODY>
<h2>Testing JSP</h2>
<jsp:useBean id="obj1" class="app.MyBean" scope="page" />
<c:set var="param1" value="Z"/>
<jsp:setProperty name="obj1" property="paramInfo" value="$param1" />
<c:set var="list1" value="$obj1.getStuff('')"/>
<c:forEach var="item" items="$list1">
<br/>ITEM: $item
</c:forEach>
<br><br>
<select name="list">
<c:forEach items="$list1" var="item">
<option value="$item"><c:out value="$item" /></option>
</c:forEach>
</select>
</BODY>
NOTE: The bean's method signature still remains same. The value passed to the method is a blank String
. The tag <jsp:setProperty ...
actually sets the parameter value.
This way you get to use the parameter value in the paramInfo
property within the getStuff
method.
The Result:
ITEM: A
ITEM: B
ITEM: C
ITEM: Z
NOTE: One can change the doStuff
method in the bean class not to accept the parameter, with this approach of setting the parameter separately.
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,getoutlet(String idDB)
need to begetOutlet(String idDB)
.
– prasad_
Nov 15 '18 at 10:32
|
show 7 more comments
Here is an approach (a work around).
The Bean Class:
public class MyBean
private String paramInfo;
public void setParamInfo(String p)
paramInfo = p;
public String getParamInfo()
return paramInfo;
public List<String> getStuff(String param)
param = paramInfo; // substitute the value here
List <String> list1 = Arrays.asList("A", "B", "C");
List<String> list2 = new ArrayList<>();
list2.addAll(list1);
list2.add(param); // use the param value here
return list2;
NOTE: I have not changed the signature of the method getStuff(String param)
; this still accepts a String
parameter. I have added a new bean property which is a substitute for the parameter value. Note the usage of the bean's new property value paramInfo
.
The JSP Page:
<BODY>
<h2>Testing JSP</h2>
<jsp:useBean id="obj1" class="app.MyBean" scope="page" />
<c:set var="param1" value="Z"/>
<jsp:setProperty name="obj1" property="paramInfo" value="$param1" />
<c:set var="list1" value="$obj1.getStuff('')"/>
<c:forEach var="item" items="$list1">
<br/>ITEM: $item
</c:forEach>
<br><br>
<select name="list">
<c:forEach items="$list1" var="item">
<option value="$item"><c:out value="$item" /></option>
</c:forEach>
</select>
</BODY>
NOTE: The bean's method signature still remains same. The value passed to the method is a blank String
. The tag <jsp:setProperty ...
actually sets the parameter value.
This way you get to use the parameter value in the paramInfo
property within the getStuff
method.
The Result:
ITEM: A
ITEM: B
ITEM: C
ITEM: Z
NOTE: One can change the doStuff
method in the bean class not to accept the parameter, with this approach of setting the parameter separately.
Here is an approach (a work around).
The Bean Class:
public class MyBean
private String paramInfo;
public void setParamInfo(String p)
paramInfo = p;
public String getParamInfo()
return paramInfo;
public List<String> getStuff(String param)
param = paramInfo; // substitute the value here
List <String> list1 = Arrays.asList("A", "B", "C");
List<String> list2 = new ArrayList<>();
list2.addAll(list1);
list2.add(param); // use the param value here
return list2;
NOTE: I have not changed the signature of the method getStuff(String param)
; this still accepts a String
parameter. I have added a new bean property which is a substitute for the parameter value. Note the usage of the bean's new property value paramInfo
.
The JSP Page:
<BODY>
<h2>Testing JSP</h2>
<jsp:useBean id="obj1" class="app.MyBean" scope="page" />
<c:set var="param1" value="Z"/>
<jsp:setProperty name="obj1" property="paramInfo" value="$param1" />
<c:set var="list1" value="$obj1.getStuff('')"/>
<c:forEach var="item" items="$list1">
<br/>ITEM: $item
</c:forEach>
<br><br>
<select name="list">
<c:forEach items="$list1" var="item">
<option value="$item"><c:out value="$item" /></option>
</c:forEach>
</select>
</BODY>
NOTE: The bean's method signature still remains same. The value passed to the method is a blank String
. The tag <jsp:setProperty ...
actually sets the parameter value.
This way you get to use the parameter value in the paramInfo
property within the getStuff
method.
The Result:
ITEM: A
ITEM: B
ITEM: C
ITEM: Z
NOTE: One can change the doStuff
method in the bean class not to accept the parameter, with this approach of setting the parameter separately.
edited Nov 15 '18 at 10:43
answered Nov 15 '18 at 10:07
prasad_prasad_
1,5681618
1,5681618
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,getoutlet(String idDB)
need to begetOutlet(String idDB)
.
– prasad_
Nov 15 '18 at 10:32
|
show 7 more comments
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,getoutlet(String idDB)
need to begetOutlet(String idDB)
.
– prasad_
Nov 15 '18 at 10:32
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
hey i have a doubt
– user10561216
Nov 15 '18 at 10:19
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
Please ask any clarifications freely.
– prasad_
Nov 15 '18 at 10:20
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
i have updated my java class look its giving me list [jayanagar,malleshwaram,kolar] i just want to populate them in a select option tag as a dropdown
– user10561216
Nov 15 '18 at 10:26
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
Here is one: Filling HTML <select> dropdown list in JSP with values fetched from database. So, what is the issue?
– prasad_
Nov 15 '18 at 10:29
In your code: The bean's getter method signature must be of format getProperty. So,
getoutlet(String idDB)
need to be getOutlet(String idDB)
.– prasad_
Nov 15 '18 at 10:32
In your code: The bean's getter method signature must be of format getProperty. So,
getoutlet(String idDB)
need to be getOutlet(String idDB)
.– prasad_
Nov 15 '18 at 10:32
|
show 7 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313923%2fcforeach-not-getting-the-values-if-a-pass-a-parameter-to-the-list-method%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Here is a post with a similar issue: How to call parameterized method from JSP using JSTL/EL.
– prasad_
Nov 15 '18 at 8:20
@prasad_ all answer there have some issues :(
– user10561216
Nov 15 '18 at 9:25
Yes, but one can try some work around. Are you allowed to change some code in the
com.touchpoint.Dao.Outlet
Java class?– prasad_
Nov 15 '18 at 9:50
@prasad_ yes for sure
– user10561216
Nov 15 '18 at 9:56