I have to populate simple combobox,so on Submit button <option values > for combobox should be carried through request global,and action should stay on same page.
But when I debug jsp I see that request stays empty???
Also combobox behave funny,it changes value when pressed any button on page???
form from line 55 to 65 behaves funny
here's the code:
<%--
Document : index
Created on : 26-Mar-2011, 22:32:32
Author : moje ime
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Glavna Forma</title>
</head>
<body>
<h1>Glavna Forma</h1>
<jsp:useBean id="b1" scope="application" class="pak.GlavnaForma">
</jsp:useBean>
<%//<jsp:setProperty name="b1" property="kombo" value="Studenti" />
/* if(session.getAttribute("kombo") != "Studenti" || session.getAttribute("kombo") != "Predmeti")
session.setAttribute("kombo", "Studenti");
if(request.getParameter( "cmbx" ) == "Studenti" || request.getParameter( "cmbx" ) == "Predmeti")
session.setAttribute("kombo", request.getParameter( "cmbx" ));
*/
if(b1.getKombo() != "Studenti" || b1.getKombo() != "Predmeti")
b1.setKombo("Studenti");
if(request.getParameter( "cmbx" ) == "Studenti" || request.getParameter( "cmbx" ) == "Predmeti")
b1.setKombo(request.getParameter("cmbx"));
out.print("<h1>"+ b1.kombo +"</h1> </br>");
//if(b1.kombo == null) b1.setKombo("Studenti");
if(b1.getKombo().equals("Studenti"))
{
b1.vratiStudente();
}
if(b1.getKombo().equals("Predmeti"))
{
b1.vratiPredmete();
}
// out.print("<h1>"+ request.getParameter("drop1") +"</h1> </br>");
%>
<table width="100" height="252" border="1" cellpadding="1" cellspacing="1">
<tr>
<form id="form1" name="form1" method="post" action="">
<th height="43" colspan="2" scope="col">
<select name="cmbx" id="cmbx" style="width:150px">
<option value="Studenti">Studenti</option>
<option value="Predmeti">Predmeti</option>
</select>
</th>
<th width="72" scope="col">
<input type="submit" name="prikazi" id="prikazi" value="Prikazi" />
</th>
</form>
</tr>
<form id="form4" name="form4" method="post" action="student.jsp">
<tr>
<td height="168" colspan="3">
<select name="drop1" id="Select1" size="4" multiple="multiple" style="width:230px;height:200px;">
<option value="1">pera peric</option>
<option value="2">item 2</option>
<option value="3">item 3</option>
<%
if(b1 != null)
if(b1.getKombo() == "Studenti")
{
for(int i=0; i<b1.studenti.size(); i++)
{
out.print("<option value=\""+i+"\">"+ b1.studenti.get(i).ime +" "+ b1.studenti.get(i).prezime + "</option>");
}
}
if(b1.getKombo() == "Predmeti")
{
for(int i=0; i<b1.predmeti.size(); i++)
{
out.print("<option value='"+i+"'>"+ b1.predmeti.get(i).naziv + "</option>");
}
}
%>
</select>
</td>
</tr>
<tr>
<td width="77" height="35">
<input type="submit" name="detalji" id="detalji" value="Detalji" />
</td>
</form>
<td width="67"><form id="form5" name="form5" method="post" action="">
<input type="submit" name="dodaj" id="dodaj" value="Dodaj" />
</form></td>
<td><form id="form6" name="form6" method="post" action="">
<input type="submit" name="obrisi" id="obrisi" value="Obrisi" />
</form></td>
</table>
</body>
</html>