Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Servlet-Interview-Questions drop down list doPost() servlet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sakai
drop down list doPost() servlet
1 Answer(s)      5 years and a month ago
Posted in : Servlet Interview Questions



Advertisement
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:
 

 

 

DMCA.com