I am trying to create a session once user log in credientials are verified. I imported the following:
import javax.servlet.http.HttpSession;
I am using the following code:
HttpSession session = request.getSession();
session.setAttribute("sessionName","sessionValue");
However I am getting the following error in relation to request
request cannot be resolved.
My full code:
package com.q1labs.qa.xmlgenerator.controller.managesession;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import javax.servlet.http.HttpSession;
import com.q1labs.qa.xmlgenerator.model.db.DbLoginQueries;
public class Login {
private DbLoginQueries query = new DbLoginQueries();
public String login(String username, String password) throws SQLException, FileNotFoundException, ClassNotFoundException, IOException{
String returnUrl = "";
//Code verifiying users credentials (Code has been removed)
//If valid is true then credentials are correct
if(valid == true){
//If credentials are correct then create a session
HttpSession session = request.getSession();
session.setAttribute("sessionName","sessionValue");
returnUrl = "home.jsp";
}else{
returnUrl = "index.jsp";
}
return returnUrl;
}
}