title: How to pass variable value from jstl to controller
body: <p>I have name and password in jsp/jstl 
   i tried to pass name and password to controller.</p>
  
  <p>this is my controller class</p>
  
  <p>package com.simple.controller;</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  @RequestMapping("/welcome")
  public class HelloController {
      private String name;
      private String password;
          private String user;
      @RequestMapping(method = RequestMethod.POST)
      public String printWelcome(ModelMap model) {
              System.out.println(user);
          model.addAttribute(name);
          model.addAttribute(password);
  
          model.addAttribute("message", "Spring 3 MVC Hello World");
          return "hello";
  
      }
  
  }
  </code></pre>
  
  <p>this is index.jsp with form tag and c tag libraries</p>
  
  <pre><code>  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1"%&gt;
      &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
      &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&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=ISO-8859-1"&gt;
      &lt;title&gt;Registration Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body bgcolor="#999966"&gt;
  &lt;p&gt;&amp;nbsp;&lt;/p&gt;
  &lt;form method="POST" action="welcome"&gt;
  
  &lt;p&gt;&lt;font color="#800000" size="5"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
  UserName:&lt;/font&gt;&lt;input type="text" name="name" size="20"&gt;&lt;/p&gt;
   &lt;c:set var="user" value="{param.name}" scope="request"&gt;
  &lt;/c:set&gt; 
  
  &lt;p&gt;&lt;font color="#800000" size="5"&gt;
  password:&lt;/font&gt;&lt;input type="text" name="password" size="20"&gt;&lt;/p&gt;
  &lt;p&gt;&lt;input type="submit" value="Submit" name="B1"&gt;&lt;/p&gt;
  &lt;/form&gt;
  &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>i am trying to pass the variable user( the value is taken from the name variable) from this form to controller.</p>
  
  <pre><code>&lt;c:set var="user" value="{param.name}" scope="request"&gt;
      &lt;/c:set&gt; 
  </code></pre>
  
  <p>can any body help me how to do this with c tags..</p>
  
  <p>i have done with using commandName="registereduser" where user is the object of class RegisteredUser.</p>
  
  <p>But i am trying with just passing the  variable (with  c tags)
  I am getting null value for user in sysout</p>
  
  <p>is there any way to do with c tags with the set</p>
  
  <p>thank you..</p>