Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request object in class

Status
Not open for further replies.

oaklanders

Technical User
Dec 9, 2007
38

How do I fetch a request value in a Java class?
Here is my attempt but it has request object error:

Code:
public class First
{
    private HttpServletRequest request;
    private String lastname;

    public First()
    {
         lastname= request.getParameter("lastname");
    }
  

    public FetchFormValue()
    {
        if(lastname.equals("Smith")
        {
             //do stuff for Smith
        }
        else
        {
            //do other stuff
        }
    }
..
}
 
The code you posted is missing initialization for "request" object. Is it initialized elsewhere in the class ?

Water is not bad as long as it remains outside human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top