title: Cannot find any information on property 'userName' in a bean of type 'com.home.homeapp.actionform.LoginForm'
body: <p>I am using Eclipse Java EE IDE, JBOSS v5.0, java version 1.5.0_16 and MySQL v5.1.0 for my application. I am trying to Authenticate to the application using Bean and Servlet In JSP.</p>
  
  <p>My Steps:</p>
  
  <p>Step:1 Create a web page  "login.jsp"  to login the user.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form name="loginform" method="post" action="loginbean.jsp"&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;table align="center"&gt;&lt;tr&gt;&lt;td&gt;&lt;h2&gt;Login Authentication&lt;/h2&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  &lt;table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;"&gt;
  &lt;tr&gt;&lt;td colspan=2&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td colspan=2&gt; &lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;b&gt;Login Name&lt;/b&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" name="userName" value=""&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="password" name="password" value=""&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="submit" name="Submit" value="Submit"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;&lt;td colspan=2&gt; &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Step:2 To create a "loginbean.jsp" to set the parameter of the login.</p>
  
  <pre><code>&lt;%@ page language="Java" import="java.sql.*" %&gt;  
  &lt;HTML&gt; 
  &lt;HEAD&gt;&lt;TITLE&gt;DataBase Search&lt;/TITLE&gt;&lt;/HEAD&gt;  
  &lt;BODY&gt;
  &lt;jsp:useBean id="db" scope="request" class="logbean.LoginBean" &gt;
    &lt;jsp:setProperty name="db" property="userName" value="&lt;%=request.getParameter("userName")%&gt;"/&gt;
    &lt;jsp:setProperty name="db" property="password" value="&lt;%=request.getParameter("password")%&gt;"/&gt;
   &lt;/jsp:useBean&gt;
  &lt;jsp:forward page="hello"&gt;
    &lt;jsp:param name="username" value="&lt;%=db.getUserName()%&gt;" /&gt;
    &lt;jsp:param name="password" value="&lt;%=db.getPassword()%&gt;" /&gt;
  &lt;/jsp:forward&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Step:3 To create a "LoginBean.java" to mapping the parameter of  "loginbean.jsp".</p>
  
  <pre><code>package logbean;
  public class LoginBean {
    String userName="";
    String password="";
    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;
    }
    }
  </code></pre>
  
  <p>Step:4 To create a  Servlet "login.java" for validate the user login.</p>
  
  <pre><code>import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.sql.*;
  import java.sql.*;
  public class login extends HttpServlet{ 
   public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException,IOException{
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    System.out.println("MySQL Connect Example.");
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "user_register";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "root"; 
    String password = "root";
   String username="";
   String userpass="";
   String strQuery= ""; 
    Statement st=null;
    ResultSet rs=null;
    HttpSession session = request.getSession(true);
    try {
    Class.forName(driver).newInstance();
    conn = DriverManager.getConnection(url+dbName,userName,password);
    if(request.getParameter("username")!=null &amp;&amp;
       request.getParameter("username")!="" &amp;&amp; request.getParameter("password")!=null &amp;&amp;
       request.getParameter("password")!="")
    {
    username = request.getParameter("username").toString();
    userpass = request.getParameter("password").toString();
    strQuery="select * from userregister where 
      username='"+username+"' and  password='"+userpass+"'";
   System.out.println(strQuery);
    st = conn.createStatement();
    rs = st.executeQuery(strQuery);
    int count=0;
    while(rs.next())
    {
    session.setAttribute("username",rs.getString(2));
    count++;
    }
    if(count&gt;0)
    {
    response.sendRedirect("welcome.jsp");
    }
    else
    {
   response.sendRedirect("login.jsp");
    }
    }
    else
    {
   response.sendRedirect("login.jsp");
    }
    System.out.println("Connected to the database"); 
    conn.close();
    System.out.println("Disconnected from database");
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
  }
  </code></pre>
  
  <p>Step :5 To create the webpage "welcome.jsp" to display the message after successful message.</p>
  
  <pre><code>&lt;HTML&gt; 
  &lt;HEAD&gt;&lt;TITLE&gt;Welcome&lt;/TITLE&gt;&lt;/HEAD&gt;  
  &lt;BODY&gt;
  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
  &lt;table align="center" style="border:1px solid #000000;"&gt;
  &lt;%
  if(session.getAttribute("username")!=null &amp;&amp; session.getAttribute("username")!="")
  {
  String user = session.getAttribute("username").toString();
  %&gt;
  &lt;tr&gt;&lt;td align="center"&gt;&lt;h1&gt;Welcome &lt;b&gt;&lt;%= user%&gt;&lt;/b&gt;&lt;/h1&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;%
  }
  %&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;html&gt;
  </code></pre>
  
  <p>BUT WHILE RUNNING THE APPLICATION FOLLOWING ERROR IS COMING:</p>
  
  <pre><code>type Exception report
  
  message
  
  description The server encountered an internal error () that prevented it from fulfilling this request.
  
  exception
  
  org.apache.jasper.JasperException: org.apache.jasper.JasperException: Cannot find any information on property 'userName' in a bean of type 'com.home.homeapp.actionform.LoginForm'
      org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:667)
      org.apache.jsp.loginbean_jsp._jspService(loginbean_jsp.java:66)
      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:369)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  
  root cause
  
  org.apache.jasper.JasperException: Cannot find any information on property 'userName' in a bean of type 'com.home.homeapp.actionform.LoginForm'
      org.apache.jasper.runtime.JspRuntimeLibrary.getWriteMethod(JspRuntimeLibrary.java:795)
      org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:664)
      org.apache.jsp.loginbean_jsp._jspService(loginbean_jsp.java:66)
      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:369)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  </code></pre>
  
  <p>note The full stack trace of the root cause is available in the JBoss Web/2.1.3.GA logs.</p>
  
  <p>PLEASE HELP ME OUT.</p>
  
  <p>Regards
  Bijoy</p>