title: Spring Mvc Passing Data from controller to jsp
body: <p>I am trying to pass data from a controller class to jsp but when I run it on server it shows null value but my id is correct and my query also returns desire result but when I get it from jsp it doesn't show any value. The error in console is 500 internal server error.
  Here is my controller code:</p>
  
  <pre><code>@RequestMapping(value = "getmoviereviewbyid/{id}", method = RequestMethod.GET)  
  public ModelAndView getMovieReviewByID(@PathVariable("id") String id) throws IOException { 
      ModelAndView
      model = new ModelAndView();         
      MovieReviewModel mrm=new MovieReviewModel();
      mrm=movieReviewDao.getMovieReviewById(Long.valueOf(id));
      model.addObject("review", mrm.getReview());
      model.addObject("movierating", mrm.getRatings());
      model.setViewName("getmoviereviewbyid");        
      return model;
  }
  </code></pre>
  
  <p>Here is the jsp code part:</p>
  
  <pre><code>function selectli(listval,id){
  $('#moviename').val(listval);
  $('#movierating').val(id);
  $('#auto').hide(800);
  $('#exist').html("Word already exist!!");
  $.ajax({
      url : "/cms/getmoviereviewbyid/"
              + id,
      type : "GET",
      success : function(results) {
          $('#moviereview').val(results.review);
      }
  });
  
  }
  </code></pre>
  
  <p>Here is my dao impl:</p>
  
  <pre><code>@Override
  public MovieReviewModel getMovieReviewById(Long id) {
    return  (MovieReviewModel) getHibernateTemplate().find("from MovieReviewModel where movie_id="+ id);
  }
  </code></pre>
  
  <p>Here is code for getting id </p>
  
  <pre><code>@RequestMapping(value = "admin_getmoviereview/{name}", method = RequestMethod.GET)
      public ModelAndView getMovieReview(
              @PathVariable("name") String name)
              throws IOException {
          ModelAndView model = new ModelAndView();
  
          try {
  
              if (name != null) {
  
                  List&lt;MovieModel&gt; tagList = new ArrayList&lt;MovieModel&gt;();
                  tagList = (List&lt;MovieModel&gt;) movieReviewDao.getMovieReviewByMovie(name);
                          //.findGallery(15441);
  
                  if (tagList.size() &gt; 0) {
  
                      Map&lt;String, Long&gt; map = new TreeMap&lt;String, Long&gt;();
  
                      for (Iterator&lt;MovieModel&gt; iterator = tagList.iterator(); iterator
                              .hasNext();) {
                          MovieModel masterModel = (MovieModel) iterator.next();
                          map.put(masterModel.getName(),
                                  (long) masterModel.getId());
                      }
                      model.addObject("typemap", map);
  
                  }
  
              }
  
          } catch (NullPointerException e) {
              // TODO: handle exception
              e.printStackTrace();
          }
  
          model.addObject("name", name);
          model.setViewName("admin_getmoviereview");
          return model;
  
      }
  </code></pre>
  
  <p>here is jsp</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
                      $( "#moviename" ).keyup(function() {
                         if($('#moviename').val().length&gt;1){
                             $.ajax({
                                    url: "/cms/getmoviereviewread?term="+ $('#moviename').val(),
                                    success: function( data ) {
                                        if(data.length&gt;0){
                                              var str ='&lt;ul style="list-style: none;"&gt;';
                                              for(var i=0;i&lt;data.length;i++){
                                                  var strtitle="'" +data[i].title + "'";
                                                  str+='&lt;li onclick="selectli('+strtitle+','+data[i].id+');"&gt;'+data[i].title+'&lt;/li&gt;';
                                              }
                                              $('#auto').html(str+'&lt;/ul&gt;');
                                              $('#auto').show(800);
                                          }else{
                                              $('#auto').hide(100);
                                               if($('#moviename').val().length&gt;1){
                                        $('#exist').html("Word Not exist!! &lt;a class = 'clickpointer' onclick='addNewWord();'&gt;Click Here&lt;/a&gt; to Add");
                                               }
                                    }}
                                  });
                         }else{
                             $('#auto').hide(100);
                         }
                  }); 
  &lt;script&gt;
  
  function selectli(listval,id){
  $('#moviename').val(listval);
  $('#movierating').val(id);
  $('#auto').hide(800);
  $('#exist').html("Word already exist!!");
  $.ajax({
      url : "/cms/getmoviereviewbyid/"
              + id,
      type : "GET",
      success : function(results) {
          $('#moviereview').val(results.review);
      }
  });
  
  }
    &lt;/script&gt;
  &lt;div class="row"&gt;
      &lt;input type="text" class="int_srh" name="q" size="" id="moviename"
          placeholder="Search movie" maxlength="120"&gt;
      &lt;div id="div0"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="row"&gt;
      &lt;input type="text" class="int_srh" name="q" size="" id="movierating"
          placeholder="Rating" maxlength="120"&gt;
  &lt;/div&gt;
  &lt;div class="row"&gt;
      &lt;input type="text" class="int_srh" name="q" size="" id="moviereview"
          placeholder="Review" maxlength="120"&gt;
  &lt;/div&gt;
  
      &lt;div id="auto"&gt;&lt;/div&gt;
      &lt;div id="meaning"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      $().ready(function() {
          $('#dialog').jqm();
      });
  &lt;/script&gt;
  [Object]
  jquery.min.js:4 GET http://localhost:8080/cms/getmoviereviewbyid/150 500 (Internal Server Error)jquery.min.js:4 m.ajaxTransport.sendjquery.min.js:4 m.extend.ajaxVM238:8 selectliVM237:37 $.ajax.successjquery.min.js:2 m.Callbacks.jjquery.min.js:2 m.Callbacks.k.fireWithjquery.min.js:4 xjquery.min.js:4 m.ajaxTransport.send.b
  </code></pre>