F
francan00
In my Tomcat 4.1.27 container (with no struts), I am trying to pass a
form value to a JavaBean.
Here is my attempt and need advise on the best way to fetch the
lastname value in my below Java class because it does compile but
gives me a NullPointerException in the JSP when I call this JavaBean:
public class First
{
private HttpServletRequest request;
private String lastname;
public First()
{
lastname= (String) request.getParameter("lastname");
}
/* Getter and Setter Methods */
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public FetchFormValue()
{
if(lastname.equals("Smith")
{
//do stuff for Smith
}
else
{
//do other stuff
}
}
...
}
Please advise.
form value to a JavaBean.
Here is my attempt and need advise on the best way to fetch the
lastname value in my below Java class because it does compile but
gives me a NullPointerException in the JSP when I call this JavaBean:
public class First
{
private HttpServletRequest request;
private String lastname;
public First()
{
lastname= (String) request.getParameter("lastname");
}
/* Getter and Setter Methods */
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public FetchFormValue()
{
if(lastname.equals("Smith")
{
//do stuff for Smith
}
else
{
//do other stuff
}
}
...
}
Please advise.