where is the userloginmid.jsp code?
userloginmid.jsp:
<%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %> <% String userName = request.getParameter("userName"); String password = request.getParameter("password"); System.out.println("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "user_register"; String driver = "com.mysql.jdbc.Driver"; String username = "root"; String userPassword = "root"; java.util.Date now = new java.util.Date(); String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); String strDateNew = sdf.format(now) ; try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,username,userPassword); Statement st = conn.createStatement(); String strQuery = "select * from userregister where username='"+userName+"' and password='"+password+"'"; //out.println(strQuery); ResultSet rs = st.executeQuery(strQuery); if(rs.next()) { int userid=rs.getInt(1); String user=rs.getString(2); session.setAttribute("userid",userid); session.setAttribute("username",user); session.setAttribute("intime",strDateNew); String queryString = "INSERT INTO admin set userid="+userid+",intime='"+strDateNew+"'"; int i = st.executeUpdate(queryString); if(i>0) { response.sendRedirect("welcome.jsp"); } } response.sendRedirect("login.jsp"); conn.close(); } catch (Exception e) { e.printStackTrace(); } %>
You can also find the above jsp code either by downloading source code of the following jsp application link:
http://www.roseindia.net/jsp/loginstatus.shtml
or through the following link
Ads