Hi All,
I am trying to call a java method in jsp. The main idea is to hide menu based on the user who logs in. Please go through the code and provide me a solution guys.
The java class flows like this,
public class UserVerification {
public static void main(String[] args) {
UserVerification obj = new UserVerification();
System.out.print(obj.GetUserVerification("abc"));
}
public int GetUserVerification(String empID) {
int roleId = 0;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
Connection connection = DriverManager.getConnection("");
PreparedStatement ps = connection.prepareStatement("");
ResultSet resultSet = ps.executeQuery();
while (resultSet.next()) {
roleId = Integer.parseInt(resultSet.getString(""));
int RoleID = 0;
UserMaster um = new UserMaster();
um.getRoleID();
while ((RoleID == roleId) && resultSet.next()) {
UserInfoDisplayController ui = new UserInfoDisplayController();
List<UserMaster> objUser = ui.GetUserInfoDisplayController(1);
System.out.print(objUser.size());
for (UserMaster um1 : objUser) {
um1.getEmpID();
um1.getUserName();
um1.getEmailID();
um1.getRoleID();
um1.getSupervisor();
um1.getTeamID();
}
}
}
ps.close();
ps.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
return roleId;
}
}
And the javascript and jsp in which i call this are shown below,
<script type="text/javascript">
function Validation(RoleID) {
alert("one");
var el = document.getElementById(cssmenu);
alert("two");
if (RoleID != 2) {
el.style.visibility == "visible";
} else {
el.style.visibility == "hidden";
}
alert("three");
}
alert("four");
</script>
<div id='cssmenu'>
<ul>
<%
if (RoleID != 2) {
%>
<li id="menu"><a href="UserMaster.jsp" >User Master</a></li>
<li id="menu"><a href="SkillMaster.jsp" >Skill Master</a></li>
<li id="menu"><a href="SkillMapping.jsp" >Skill Mapping</a></li>
<li id="menu"><a href="Report.jsp" >Reports</a></li>
<%
}
%>
<li><a href="MySkills.jsp" >My Skills</a></li>
</ul>
</div>