Scriptlets go under the body of service method. s1, here, is local to the service method. It cannot be accessed from the declaration part.
public ArrayList getEmpName() throws Exception {
ArrayList emp = new ArrayList();
String s1 = request.getParameter("name"); //Wouldn't work because the implicit request object is available only within the service method or a scriptlet.
emp = new UserRights().showEmp(s1);
return emp;
}
%>
You can modify your getEmpName() to this:
public ArrayList getEmpName(String name) throws Exception {
ArrayList emp = new ArrayList();
emp = new UserRights().showEmp(name); //showEmp() must return an ArrayList
return emp;
}
%>
And make the method call inside a scriptlet.
String empName = getEmpName(request.getParameter("name"));
%>