java - Items are not showing in dropdown list using servlet -
i've created servlet dropdown list. here code..
ddbirformno.java(servlet)
public class ddbirformno extends httpservlet { private static final long serialversionuid = 1l; @override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { tblbirformnodao birdao = daofactory.getdaomanager(tblbirformno.class); list<tblbirformno> birtypelist = birdao.getallbirformnumber(); request.setattribute("birtypelist", birtypelist); request.getrequestdispatcher("/web-inf/rcmoduleissue-ereceipt-ror.jsp").forward(request, response); } }
i don't know if missed something.
rcmoduleissue-ereceipt-ror.jsp:
<select name="bfnscode" id="bfnscode" class="sel" style="width: 245px; margin-left: 0;"> <option selected="selected" value=""></option> <c:foreach var="bircode" items="${birtypelist}"> <option value="${bircode.bfnscode}">${bircode.bfnscode}</option> </c:foreach> </select>
can please post errors, getting? in finding issues. have tried creating same structure , implement servlet , having values in dropdown , working. below code have tried, ddbirformno servlet
public class ddbirformno extends httpservlet { private static final long serialversionuid = 1l; @override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { list<tblbirformno> birtypelist = this.getallbirformnumber(); request.setattribute("birtypelist", birtypelist); request.getrequestdispatcher("/web-inf/rcmoduleissue-ereceipt-ror.jsp").forward(request, response); } private list<tblbirformno> getallbirformnumber(){ list<tblbirformno> ltblbirformno = new arraylist<tblbirformno>(); tblbirformno birformno = new tblbirformno(); birformno.setbfnscode("123"); ltblbirformno.add(birformno); birformno = new tblbirformno(); birformno.setbfnscode("456"); ltblbirformno.add(birformno); birformno = new tblbirformno(); birformno.setbfnscode("789"); ltblbirformno.add(birformno); birformno = new tblbirformno(); birformno.setbfnscode("012"); ltblbirformno.add(birformno); return ltblbirformno; } }
tblbirformno class
public class tblbirformno { public string bfnscode = null; /** * @return bfnscode */ public string getbfnscode() { return bfnscode; } /** * @param bfnscode * bfnscode set */ public void setbfnscode(string bfnscode) { this.bfnscode = bfnscode; } }
web-inf/rcmoduleissue-ereceipt-ror.jsp
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!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=iso-8859-1"> <title>insert title here</title> </head> <body> <select name="bfnscode" id="bfnscode" class="sel" style="width: 245px; margin-left: 0;"> <option selected="selected" value=""></option> <c:foreach var="bircode" items="${birtypelist}"> <option value="${bircode.bfnscode}">${bircode.bfnscode}</option> </c:foreach> </select> </body> </html>
above sample per code , working fine
Comments
Post a Comment