© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Updating the user’s operation in Log File Using Java

Description:

In Banking application, any user can perform their operations from anywhere with in the specified time for them. So, the admin can’t monitor them directly. Using this program administrator can find out their illegal operations with the help of log files. In this program when the user logon to the system their role is maintained in the session. When they are performing some operation for example credit, accessibility of the role is verified. If they are having the rights, the user is allowed to perform credit operation otherwise their access will be denied. The details of operations which are performed by the user are stored in Log File. Admin can view the operations performed by the user. Admin can check the performance later using this Log file. FileWriter and BufferedWriter classes are used for writing the operations in the Log file.

Updating the user’s operation in Log File Using Java:

/*creditcheck.java*/ <%@ page import="javax.swing.*"%> <%@ page import="java.sql.*"%> <%@ page import="java.io.*"%> <% int success = 0; String uname=(String)session.getAttribute("user"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:banks"); Statement timecheckst = con.createStatement(); ResultSet timecheckrs = timecheckst.executeQuery("select time2 from user where id='"+uname+"'"); String role=(String)session.getAttribute("roles"); System.out.println(" ROLE "+role); if(role.equals("Teller") || role.equals("General Manager") ){ //================================================================== String lvalid = (String)session.getAttribute("logintime"); long oldlogtime = Long.parseLong(lvalid); long lohst=System.currentTimeMillis(); long lof=lohst-oldlogtime; System.out.println("LOFFFFFFFFFFFFFFFFFFFFFFFFFF "+lof); if(lof>60000){JOptionPane.showMessageDialog(null,"Your Time Over! Please Log Off "); response.sendRedirect("work_user.jsp");} else{ //================================================================== response.sendRedirect("credit.jsp"); } } else{ //***********************Log File************************ String role1=(String)session.getAttribute("roles"); String namesid=(String)session.getAttribute("user"); System.out.println(" JJJJJJJJJJJJJ"); try{ String rol=(String)session.getAttribute("roles"); String IDs=(String)session.getAttribute("user"); FileWriter out1=new FileWriter("d:/LogFiles/Details.log",true); BufferedWriter out2=new BufferedWriter(out1); java.util.Date date=new java.util.Date(); int sysDate=date.getDate(); int sysMonth=date.getMonth(); int sysYear=date.getYear(); long loh1=System.currentTimeMillis(); Time sh1=new Time(loh1); String time1=String.valueOf(sh1); System.out.println(time1+" JJJJJJJJJJJJJ"); out2.newLine(); out2.write("*** "+role1+" ID :"+namesid+" Attempt To Access : Credit : Date & Time :"+new java.util.Date()+" ***"); out2.close(); out1.close(); System.out.println(sysDate); } catch(Exception e){ System.out.println(e); } //***********************Log File************************ response.sendRedirect("deni.jsp"); } %> /*log.java*/ <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <% //System.out.println("gggggggggggggggggggggggg"); FileInputStream filin = new FileInputStream("E:/LogFiles/details.log"); DataInputStream din = new DataInputStream(filin); String gets1=din.readLine(); int x=0; while(gets1!=null){ if(gets1.endsWith("***")){ System.out.println(gets1); x++; } gets1=din.readLine(); } filin.close(); din.close(); String options[]=new String[x]; FileInputStream filin1 = new FileInputStream("E:/LogFiles/details.log"); DataInputStream din1 = new DataInputStream(filin1); String gets=din1.readLine(); int x1=0; while(gets!=null){ if(gets.endsWith("***")){ System.out.println(gets); options[x1]=gets; x1++; } gets=din1.readLine(); } %>

Log Files

<% for(int o1=0;o1

    <%=o1+1%> . <%=options[o1]%>

<% } %>

Sample ScreenShot:

 
SLogix Student Projects


⇓Student Projects⇓
⇑Student Projects⇑
bottom