Hi, I am doing a project in pure JSP, Servlet, Hibernate and MySQL. I am using jsp for a presentation and Servlet for buiseness logic.
In my one jsp form there is one combobx and other textboxes are present.
My problem is that, I want to fill that combobox from the database table value.But i cant understand how it is possible by using setter/getter method.

My .jsp code snippet is....

<select name="wardNameCB" size="1" >
<option value="" selected>Select</option> 
<%Iterator itr;%>
<% List wList= (List)request.getAttribute("wList");
			
for (itr=wList.iterator(); itr.hasNext(); )
{
	String value=(String)itr.next();
	%> 
							
<option value=<%=value %>><%=value %></option> 							
<%} %>
							
</select>

My Servlet is.......

else if(act.equalsIgnoreCase("getAllWardList")) {
			log.info("inside getAllWardList Action");
			WardBo wrdbo = new WardBo();
			List wardList = wrdbo.getAllWardList(1);
			[B]List wList = new ArrayList();[/B]
			[B]wList = wrdbo.getAllWardList();
			request.setAttribute("wList",wList);[/B]
			request.setAttribute("nextPageNumber", 2);
			request.setAttribute("previousPageNumber", 1);
			request.setAttribute("wardList", wardList);
			getServletContext().getRequestDispatcher("/WardSetup.jsp").forward(request, response);
		}

Plz help me its urgent.......

Hi, I am doing a project in pure JSP, Servlet, Hibernate and MySQL. I am using jsp for a presentation and Servlet for buiseness logic.
In my one jsp form there is one combobx and other textboxes are present.
My problem is that, I want to fill that combobox from the database table value.But i cant understand how it is possible by using setter/getter method.

My .jsp code snippet is....

<select name="wardNameCB" size="1" >
<option value="" selected>Select</option> 
<%Iterator itr;%>
<% List wList= (List)request.getAttribute("wList");
			
for (itr=wList.iterator(); itr.hasNext(); )
{
	String value=(String)itr.next();
	%> 
							
<option value=<%=value %>><%=value %></option> 							
<%} %>
							
</select>

My Servlet is.......

else if(act.equalsIgnoreCase("getAllWardList")) {
			log.info("inside getAllWardList Action");
			WardBo wrdbo = new WardBo();
			List wardList = wrdbo.getAllWardList(1);
			[B]List wList = new ArrayList();[/B]
			[B]wList = wrdbo.getAllWardList();
			request.setAttribute("wList",wList);[/B]
			request.setAttribute("nextPageNumber", 2);
			request.setAttribute("previousPageNumber", 1);
			request.setAttribute("wardList", wardList);
			getServletContext().getRequestDispatcher("/WardSetup.jsp").forward(request, response);
		}

Plz help me its urgent.......

Hi,

Try 2 set WList in context scope and retrieve it in Jsp using Application implicit variable.

shantechi>Try 2 set WList in context scope and retrieve it in Jsp using Application ? implicit variable.

To make the use of request's attributes in your JSP page.
1. Request the Servlet and
2. Servlet forwards a JSP WardSetup.jsp in which WList is set at request scope.

This article has been dead for over six months. Start a new discussion instead.