D
deepstar
Hi masterprogrammers
I have a problem with my code, I can print out the text from my
textbox, but I can't print out the chosen option in my option box which
is generated from my Sql data (this is all on a single jsp page). I
have marked the line that tries to output the chosen listvalue but
which fails with //Doesn't work
Been trying for ages now, can anyone give me some hints?? thx
String chosenItem=request.getParameter("listedItem");
String[] getOptionValue = request.getParameterValues("listedItem");
String addedTagValue = null;
session.setAttribute("addedTags", addedTags);
session.setAttribute("listedItem", chosenItem);
%>
<H3>Items:</H3>
<SELECT SIZE="1" NAME="listedItem"> //The droplist
<%
//Read item names, generate droplist
ResultSet rslt = addStmt.executeQuery("SELECT name FROM
personal_item");
ResultSetMetaData rsmd = rslt.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
while(rslt.next()) {
String getItemName = rslt.getString(i);
getItemName = rslt.getString("name");
out.println("<option value='"+getItemName+"'>"
+getItemName+ "</option>");
}
}
rslt.close();
addStmt.close();
connection.close();%>
</SELECT>
<FORM METHOD="POST" ACTION="update.jsp?add=yes">
<BR/><BR/>
<H3>Tags:</H3>
<INPUT TYPE="text" NAME="addedTags" value=""><BR/><BR/>
<INPUT TYPE="submit" VALUE="submit">
<BR/>
</FORM>
<BR/>
<BR/>
<%
//Set Item tag
try {
if(request.getParameter("add").equals("yes")) {
out.println(addedTags);
//Works
for (int j = 0; j < getOptionValue.length; j++) {
out.println(getOptionValue[j]);
//Doesn't work
}
addStmt.close();
connection.close();
}
} catch (NullPointerException e)
{
} %>
I have a problem with my code, I can print out the text from my
textbox, but I can't print out the chosen option in my option box which
is generated from my Sql data (this is all on a single jsp page). I
have marked the line that tries to output the chosen listvalue but
which fails with //Doesn't work
Been trying for ages now, can anyone give me some hints?? thx
String chosenItem=request.getParameter("listedItem");
String[] getOptionValue = request.getParameterValues("listedItem");
String addedTagValue = null;
session.setAttribute("addedTags", addedTags);
session.setAttribute("listedItem", chosenItem);
%>
<H3>Items:</H3>
<SELECT SIZE="1" NAME="listedItem"> //The droplist
<%
//Read item names, generate droplist
ResultSet rslt = addStmt.executeQuery("SELECT name FROM
personal_item");
ResultSetMetaData rsmd = rslt.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); i++) {
while(rslt.next()) {
String getItemName = rslt.getString(i);
getItemName = rslt.getString("name");
out.println("<option value='"+getItemName+"'>"
+getItemName+ "</option>");
}
}
rslt.close();
addStmt.close();
connection.close();%>
</SELECT>
<FORM METHOD="POST" ACTION="update.jsp?add=yes">
<BR/><BR/>
<H3>Tags:</H3>
<INPUT TYPE="text" NAME="addedTags" value=""><BR/><BR/>
<INPUT TYPE="submit" VALUE="submit">
<BR/>
</FORM>
<BR/>
<BR/>
<%
//Set Item tag
try {
if(request.getParameter("add").equals("yes")) {
out.println(addedTags);
//Works
for (int j = 0; j < getOptionValue.length; j++) {
out.println(getOptionValue[j]);
//Doesn't work
}
addStmt.close();
connection.close();
}
} catch (NullPointerException e)
{
} %>