Hi i am trying to set my bean values from a html form (login.html) parameters into a
jsp bean.the parameter from form first goes to a
servlet named ELTest.java where i instantiate the bean and then bound that bean in request attribute and forward it to a jsp named first.jsp where bean value is supposed to be set using parameters.but the problem is when i output that value it shows null. please help me
here is jsp
--first.jsp--
<jsp:useBean id="Employee" type="com.example.model.Employee" scope="request" >
<jsp:setProperty name="Employee" property="ID"/>
</jsp:useBean>
<jsp:getProperty name="Employee" property="ID"/>
here is bean
--Employee.java--
package com.example.model;
public class Employee
{
private int ID;
public Employee(){}
public void setID(int ID)
{
this.ID=ID;
}
public int getID()
{
return ID;
}
}
here is servlet
--ELTest.java--
//
// ELTest.java
//
//
// Created by Harsh Gupta on 06/11/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
package com.example.web;
import javax.servlet.*;
import com.example.model.*;
import javax.servlet.http.*;
//import java.io.*;
//import java.util.*;
public class ELTest extends HttpServlet
{
String name,ID,name_ID;
//Map<String,String> musicMap =new HashMap<String,String>();
//ArrayList<String> myFood=new ArrayList<String>();
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
{
name=request.getParameter("name");
ID=request.getParameter("ID");
name_ID=name+ID;
if(name_ID!=null)
{
Employee e=new Employee();
request.setAttribute("Employee",e);
//request.setAttribute("User_info",name_ID);
request.getRequestDispatcher("first.jsp").forward(request,response);
}
}
}