title: Spring MVC : unable to display drop down
body: <p>I am  not getting the drop down value in Profession. Actually I am getting exception</p>
  
  <pre><code>javax.servlet.ServletException: Type [java.lang.String] is not valid for option items
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
      org.apache.jsp.WEB_002dINF.views.Registration_jsp._jspService(org.apache.jsp.WEB_002dINF.views.Registration_jsp:85)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
  root cause
  
  javax.servlet.jsp.JspException: Type [java.lang.String] is not valid for option items
      org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(OptionWriter.java:142)
      org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:223)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:103)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      org.apache.jsp.WEB_002dINF.views.Registration_jsp._jspx_meth_form_select_0(org.apache.jsp.WEB_002dINF.views.Registration_jsp:283)
      org.apache.jsp.WEB_002dINF.views.Registration_jsp._jspx_meth_form_form_0(org.apache.jsp.WEB_002dINF.views.Registration_jsp:144)
  </code></pre>
  
  <p>I understand something wrong with select tag .</p>
  
  <h1>    please help</h1>
  
  <h1>RegisterController</h1>
  
  <pre><code>package net.codejava.spring.controller;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import net.codejava.spring.model.User;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  @RequestMapping(value = "/register")
  public class RegisterController {
  
      @RequestMapping(method = RequestMethod.GET)
      public ModelAndView initForm() {
          User user = new User();
          user.setUsername("Anukul");
          ModelAndView mav = new ModelAndView("Registration");
          //=== default user name======
          //model.addAttribute("userNameDefault", "Enter Name");
          mav.addObject("userNameDefault", "Enter Name");
  
          //==== creating drop down list =====
          Map&lt;String,String&gt; profDropDown = new HashMap&lt;String, String&gt;();
          profDropDown.put("Lecturer", "Lecturer");
          profDropDown.put("proff", "proff");
  
  //      //==== adding drop down to user ====
          mav.addObject("ProffesionList", profDropDown);
          mav.addObject("user",user);
          //==== user added to model =========
  
          return mav;
      }
  
      @RequestMapping(method = RequestMethod.POST)
      public String submitForm(Model model,@ModelAttribute User user) {
  
          model.addAttribute(user);
  
          // implement your own registration logic here...
          return "RegistrationSuccess";
      }
  </code></pre>
  
  <h2>    }</h2>
  
  <h1>Registration.jsp</h1>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Registration&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div align="center"&gt;
      &lt;h1&gt;reached here&lt;/h1&gt;
          &lt;form:form action="register" method="POST" commandName="user"&gt;
              &lt;table border="0"&gt;
                  &lt;tr&gt;
                      &lt;td colspan="2" align="center"&gt;&lt;h2&gt;Spring MVC Form Demo - Registration&lt;/h2&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;User Name:&lt;/td&gt;
                      &lt;td&gt;&lt;form:input path="username"  /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Password:&lt;/td&gt;
                      &lt;td&gt;&lt;form:password path="password" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;E-mail:&lt;/td&gt;
                      &lt;td&gt;&lt;form:input path="email" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Birthday (mm/dd/yyyy):&lt;/td&gt;
                      &lt;td&gt;&lt;form:input path="birthDate" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt; 
                      &lt;td&gt;Profession:&lt;/td&gt; 
                      &lt;td&gt;&lt;form:select path="profession" items="${ProffesionList}" /&gt;&lt;/td&gt; 
                  &lt;/tr&gt; 
                  &lt;tr&gt;
                      &lt;td colspan="2" align="center"&gt;&lt;input type="submit" value="Register" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/form:form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <h1>User.java</h1>
  
  <pre><code>package net.codejava.spring.model;
  
  import java.util.Date;
  
  public class User {
      private String username;
      private String password;
      private String email;
      private Date birthDate;
      private String profession;
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public Date getBirthDate() {
          return birthDate;
      }
  
      public void setBirthDate(Date birthDate) {
          this.birthDate = birthDate;
      }
  
      public String getProfession() {
          return profession;
      }
  
      public void setProfession(String profession) {
          this.profession = profession;
      }
  
  }
  ----------------
  </code></pre>