Hi all,
I want to retrieve selected item from listbox in a jsp page and send it to a servlet. I am not able to get selected value. Can u please tell me how to get selected value.

In servlet i am trying to get the selected value by using getparameter() function, but its not working.

This is the code i hve given in jsp page:

<%@ page language="java" import="java.util.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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>Unblock Page</title>
</head><br><br>

<body background ="bluebg1.jpg" text="DarkBlue">

<select name = "urllist" size="1" >
<%Iterator itr;%>
<% List data= (List)request.getAttribute("data");
for (itr=data.iterator(); itr.hasNext(); )
{
	String s=itr.next().toString();
%>
<option value = "<%=s%>" >  <%=s%> </option>
<%}%>
</select>

<form action="./unblock" method="post"><h1 align="center"><input type="submit" value="Unblock" ></h1></form>
<%

String urllist = request.getParameter("urllist");
System.out.println("String in jsp"+urllist);
%>

</body>
</html>

Your <select> element (and also any other element eg textfields, checkboxes, etc ) should be inside the <form> </form> tags, if you want your data to get posted (via GET or POST) to the URL specified in the form's action parameter.
From what I see you seem to have no idea how HTML forms work, so I would suggest this tutorial.

And PLEASE use code tags, when you are pasting code. You can read about them here.
This is already your fourth post in roughly 7-8 months and the fact that you still haven't read the rules only shows your ignorance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.