create one javabean which should have set and get methods.
ex: TestBean.java
class TestBean{
int id ;
public void setId(int id){
this.id =id;
}
public int getId(){
return this.id;
}
}
in servlet, create instance of that bean.
TestBean tb = new TestBean();
td.setId(3); // i am setting id as 3 in TestBean.
request.setAttribute("TestBean",tb);
//then forward this servlet to JSP.
in JSP,
after defining page attributes...
don't forget to import ur bean package.
TestBean tb = (TestBean) request.getAttribute("TestBean");
int id = tb.getId();
out.println("id is"+id); // it will print 3 in ur jsp page.
all the best.