title: how to pass data to controller actions in extjs or jsp(I don't know what I have to use) by using MVC architecture?
body: <p>In login screen. I want to check user by connecting database. But I have to do it in Java MVC architecture.</p>
  
  <p>Firstly,
  In login.js  I want to reach the login.action which is in Contact controller and it Finally, returns the json array as success or failed. Then I go to services and DAO.</p>
  
  <p>Also, I am new programmer at java mvc architecture how to use it in there?</p>
  
  <p>MY contact controller codes are below:</p>
  
  <pre><code>package com.loiane.web;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import com.loiane.model.Contact;
  import com.loiane.service.ContactService;
  
  
  @Controller
  public class ContactController  {
  
  private ContactService contactService;
  
  @RequestMapping(value="/contact/view.action")
  public @ResponseBody Map&lt;String,? extends Object&gt; view() throws Exception {
  
      try{
  
          List&lt;Contact&gt; contacts = contactService.getContactList();
  
          return getMap(contacts);
  
      } catch (Exception e) {
  
          return getModelMapError("Error retrieving Contacts from database.");
      }
  }
  
  @RequestMapping(value="/contact/login.action")
  public @ResponseBody Boolean login(@RequestParam Object data) throws Exception {
  
      try{
  
          Boolean res = contactService.login(data);
      return res;
      } catch (Exception e) {
  
  
      }
      return false;
  }
  
  @RequestMapping(value="/contact/create.action")
  public @ResponseBody Map&lt;String,? extends Object&gt; create(@RequestParam Object data) throws Exception {
  
      try{
  
          List&lt;Contact&gt; contacts = contactService.create(data);
  
          return getMap(contacts);
  
      } catch (Exception e) {
  
          return getModelMapError("Error trying to create contact.");
      }
  }
  
  @RequestMapping(value="/contact/update.action")
  public @ResponseBody Map&lt;String,? extends Object&gt; update(@RequestParam Object data) throws Exception {
      try{
  
          List&lt;Contact&gt; contacts = contactService.update(data);
  
          return getMap(contacts);
  
      } catch (Exception e) {
  
          return getModelMapError("Error trying to update contact.");
      }
  }
  
  @RequestMapping(value="/contact/delete.action")
  public @ResponseBody Map&lt;String,? extends Object&gt; delete(@RequestParam Object data) throws Exception {
  
      try{
  
          contactService.delete(data);
  
          Map&lt;String,Object&gt; modelMap = new HashMap&lt;String,Object&gt;(3);
          modelMap.put("success", true);
  
          return modelMap;
  
      } catch (Exception e) {
  
          return getModelMapError("Error trying to delete contact.");
      }
  }
  
  /**
   * Generates modelMap to return in the modelAndView
   * @param contacts
   * @return
   */
  private Map&lt;String,Object&gt; getMap(List&lt;Contact&gt; contacts){
  
      Map&lt;String,Object&gt; modelMap = new HashMap&lt;String,Object&gt;(3);
      modelMap.put("total", contacts.size());
      modelMap.put("data", contacts);
      modelMap.put("success", true);
  
      return modelMap;
  }
  
  /**
   * Generates modelMap to return in the modelAndView in case
   * of exception
   * @param msg message
   * @return
   */
  private Map&lt;String,Object&gt; getModelMapError(String msg){
  
      Map&lt;String,Object&gt; modelMap = new HashMap&lt;String,Object&gt;(2);
      modelMap.put("message", msg);
      modelMap.put("success", false);
  
      return modelMap;
  } 
  
  
  @Autowired
  public void setContactService(ContactService contactService) {
      this.contactService = contactService;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My Login.js codes are below:</p>
  
  <pre><code>Ext.onReady(function(){
  Ext.QuickTips.init();
  
  // Create a variable to hold our EXT Form Panel. 
  // Assign various config options as seen.    
  var login = new Ext.FormPanel({ 
      labelWidth:80,
      url:'Login.jsp', 
      frame:true, 
      title:'Lütfen Giriş Yapınız.', 
      defaultType:'textfield',
  monitorValid:true,
  // Specific attributes for the text fields for username / password. 
  // The "name" attribute defines the name of variables sent to the server.
      items:[{ 
              fieldLabel:'Kullanıcı Adı', 
              name:'loginUsername', 
              allowBlank:false 
          },{ 
              fieldLabel:'Parola', 
              name:'loginPassword', 
              inputType:'password', 
              allowBlank:false 
          }],
  
  // All the magic happens after the user clicks the button     
      buttons:[{ 
              text:'Login',
              formBind: true,  
              // Function that fires when user clicks the button 
              handler:function(){ 
                  login.getForm().submit({ 
                      method:'POST', 
                      waitTitle:'Connecting', 
                      waitMsg:'Sending data...',
  
          // Functions that fire (success or failure) when the server responds. 
          // The one that executes is determined by the 
          // response that comes from login.asp as seen below. The server would 
          // actually respond with valid JSON, 
          // something like: response.write "{ success: true}" or 
          // response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}" 
          // depending on the logic contained within your server script.
          // If a success occurs, the user is notified with an alert messagebox, 
          // and when they click "OK", they are redirected to whatever page
          // you define as redirect. 
  
                      success:function(){ 
                          Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
                 if (btn == 'ok'){
                              var redirect = 'home.jsp'; 
                              window.location = redirect;
                                 }
                  });
                      },
  
          // Failure function, see comment above re: success and failure. 
          // You can see here, if login fails, it throws a messagebox
          // at the user telling him / her as much.  
  
                      failure:function(form, action){ 
                          if(action.failureType == 'server'){ 
                              obj = Ext.util.JSON.decode(action.response.responseText); 
                              Ext.Msg.alert('Login Failed!', obj.errors.reason); 
                          }else{ 
                              Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText); 
                          } 
                          var redirect = 'home.jsp'; 
                          window.location = redirect;
                      } 
                  }); 
              } 
          }] 
  });
  
  
  // This just creates a window to wrap the login form. 
  // The login object is passed to the items collection.       
  var win = new Ext.Window({
      layout:'fit',
      width:300,
      height:150,
      closable: false,
      resizable: false,
      plain: true,
      border: false,
      items: [login]
  });
  win.show();
  </code></pre>
  
  <p>});</p>
  
  <p>Finally: Login.jsp codes are below:(Also, I don't know what I have to do in jsp so. İt is necessary and What do I code in jsp).</p>
  
  <pre><code>&lt;%@page import="com.loiane.web.ContactController"%&gt;
  &lt;%@ page language="java" pageEncoding="UTF-8"%&gt;
   &lt;%
  String result;
      String loginUsername = request.getParameter("loginUsername");
      String loginPassword = request.getParameter("loginPassword");
  
   if ((null != loginUsername &amp;&amp; loginUsername.length() &gt; 0) &amp;&amp; (null != loginPassword &amp;&amp; loginPassword.length() &gt; 0)) {
  
      if (loginUsername.equals("f"))
          //check
  
          result = "{success:true}";
      else
          result = "{success:false,errors:{reason:'Login failed.Try again'}}";
  
  } else {
      result = "{success:false,errors:{reason:'Login failed.Try again'}}";
  }
  </code></pre>
  
  <p>%></p>