title: SpringMVC Errors
body: <p><strong>CASE1:</strong>
  Iam getting below error :</p>
  
  <pre><code> org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 14
  
  11: &lt;body&gt;
  12:     
  13:     
  14:      &lt;form:form  method="get" commandName="user" action="login"&gt;
  15:      
  16:         &lt;form:label path="Username" /&gt;&lt;form:input path="uname"/&gt;
  17:         &lt;form:label path="Password" /&gt;&lt;form:input path="password"/&gt;
  
  
  Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:521)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:424)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  root cause
  
  java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
      org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:90)
      org.springframework.web.servlet.support.RequestContextUtils.getWebApplicationContext(RequestContextUtils.java:85)
      org.springframework.web.servlet.support.RequestContext.initContext(RequestContext.java:209)
      org.springframework.web.servlet.support.JspAwareRequestContext.initContext(JspAwareRequestContext.java:74)
      org.springframework.web.servlet.support.JspAwareRequestContext.&lt;init&gt;(JspAwareRequestContext.java:48)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
      org.apache.jsp.login_jsp._jspx_meth_form_005fform_005f0(login_jsp.java:111)
      org.apache.jsp.login_jsp._jspService(login_jsp.java:76)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p><strong>WHEN IAM USING BELOW FORM:</strong></p>
  
  <pre><code>&lt;form:form  method="post" commandName="user" action="login"&gt;
  
          &lt;form:label path="Username" /&gt;&lt;form:input path="uname"/&gt;
          &lt;form:label path="Password" /&gt;&lt;form:input path="password"/&gt;
  
          &lt;input type="submit" value="Submit" /&gt;
       &lt;/form:form&gt;
  </code></pre>
  
  <p><strong>CASE2:</strong>
  Iam getting 404 after when I SUBMITTED below form, I mean this url : <code>http://localhost:8443/BugTrackingSystem/login</code></p>
  
  <p><strong>WHEN IAM USING BELOW FORM:</strong></p>
  
  <pre><code>&lt;form action="login" method="post"&gt;
          Username: &lt;input type="text" name="uname"&gt;
          Password: &lt;input type="text" name="password"&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>OTHER FILES:</strong>
  *<em>LOGINCONTROLLER:</em>*</p>
  
  <pre><code>package com.bts.controller;
  
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.validation.BindException;
  import org.springframework.web.servlet.ModelAndView;
  import org.springframework.web.servlet.mvc.AbstractFormController;
  import org.springframework.web.servlet.mvc.SimpleFormController;
  
  import com.bts.vo.User;
  
  public class LoginController extends SimpleFormController{
  
  
       public LoginController(){
              setCommandClass(User.class);
              setCommandName("user");
          }
  
  
  
       protected ModelAndView onSubmit(Object obj) throws ServletException {
  
           User user = (User) obj;
              System.out.println("username: "+user.getUname());
  
  
          return new ModelAndView("index","user", user);
  
       }
  
  
  }
  </code></pre>
  
  <p><strong>WEB.XML</strong></p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5"&gt;
      &lt;display-name&gt;BugTrackingSystem&lt;/display-name&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;login.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/application-context.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  
      &lt;listener&gt;
          &lt;listener-class&gt;
              org.springframework.web.context.ContextLoaderListener
          &lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;
              org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
          &lt;load-on-startup&gt;2&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>USER.JAVA</strong></p>
  
  <pre><code>package com.bts.vo;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class User {
  
      public User() {
  
          countries = new ArrayList&lt;String&gt;();
  
          countries.add("India");
          countries.add("US");
  
      }
  
      private String uname;
      private String password;
      private List&lt;String&gt; countries;
  
      public String getUname() {
          return uname;
      }
      public void setUname(String uname) {
          this.uname = uname;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
      public List&lt;String&gt; getCountries() {
          return countries;
      }
      public void setCountries(List&lt;String&gt; countries) {
          this.countries = countries;
      }
  
  }
  </code></pre>
  
  <p><strong>DISPATCHER-SERVLET.XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans     
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
  
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:order="1"&gt;
          &lt;property name="prefix"&gt;
              &lt;value&gt;/WEB-INF/jsp/&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="suffix"&gt;
              &lt;value&gt;.jsp&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;     
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>CONTROLLERS-BEANS.XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans     
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
  
  
      &lt;bean name="login" class="com.bts.controller.LoginController"&gt;
          &lt;property name="successView" value="index" /&gt;
      &lt;/bean&gt;
  
      &lt;bean name="productDetails"
          class="com.bts.controller.ProductDetailsController"&gt;
      &lt;/bean&gt;
  
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>application-context.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xsi:schemaLocation="
          http://www.springframework.org/schema/beans     
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
    &lt;import resource="dispatcher-servlet.xml"/&gt;
    &lt;import resource="controllers-beans.xml"/&gt;
    &lt;import resource="datasource.xml"/&gt;
    &lt;import resource="hibernate-beans.xml"/&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I am learning right now Spring, so I'm facing above problems, so please provide me a solution, I will use Annotations later after when I understood this issue.. </p>