drop down list doPost() servlet

drop down list doPost() servlet

View Answers

December 9, 2009 at 10:56 AM

Hi Friend,

index.jsp:

<html>
<form method="post" action="../DropDown">
<select name="Feedback" multiple="multiple">
<option> "Poor"</option>
<option>"Good"</option>
<option>"Very Good"</option>
<option>"Excellent"</option>
</select>
<input type="Submit" value="Submit">
</form>
</html>

DropDown.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DropDown extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException{
PrintWriter out = response.getWriter();
String selectedValues[]=request.getParameterValues("Feedback");
out.print("Selected Values are: ");
for(int i=0;i<selectedValues.length;i++){
out.print(selectedValues[i]);
}
}
}

web.xml:

<servlet>
<servlet-name>DropDown</servlet-name>
<servlet-class>DropDown</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DropDown</servlet-name>
<url-pattern>/DropDown</url-pattern>
</servlet-mapping>

Thanks









Related Tutorials/Questions & Answers:

Ads