Share on Google+Share on Google+

Sonal jain
userloginmid.jsp
1 Answer(s)      5 years ago
Posted in : JSP-Interview Questions

where is the userloginmid.jsp code?

Ads

View Answers

April 6, 2012 at 11:56 AM


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

http://www.roseindia.net/jsp/javascriptpagerefresh.shtml










Related Tutorials/Questions & Answers:
userloginmid.jsp
userloginmid.jsp   where is the userloginmid.jsp code?   userloginmid.jsp: <%@ page import="java.sql.*,java.util.*,java.text.*,java.text.SimpleDateFormat" %> <% String userName = request.getParameter
How To Page Refresh Using JavaScript In JSP
="userloginmid.jsp" url=url+"?username="+username+"&...;   Step 3:Create a web page (userloginmid.jsp) to retieve
Advertisements
Record user login and logout timing In JSP
;userloginmid.jsp", "welcome.jsp","logout.jsp" and "...;loginform" method="post" action="userloginmid.jsp"
ma access reading values
="userloginmid.jsp" url=url+"?username="+username+"&password
ma access reading values
="userloginmid.jsp" url=url+"?username="+username+"&password
ms access
="userloginmid.jsp" url=url+"?username="+username+"&password="+password
ms access
="userloginmid.jsp" url=url+"?username="+username+"&password="+password
ms access
="userloginmid.jsp" url=url+"?username="+username+"&password="+password
ms access
="userloginmid.jsp" url=url+"?username="+username+"&password="+password
Tutorials   
Java Spring Hibernate Struts Training why do not required application restart after jsp changes? How to use contentType Attribute in JSP? How to connect to MySQL in JSP? JSP Comment Types with example How to use ajax in jsp? How to access the database from JSP? how to show image as a link which path coming from database jsp netbeans javascript Logos on mail inbox. I want to update the multiple values of database depending on checkbox..? Please help me out.. jsp 18/04/2013 JSTL how to access element added via javascript dynamically using jsp code Electronic spreadsheets are useful in situation An E-mail protocol for storage JSP JSP JSP jsp servlets Exception: com.mysql.jdbc.Driver display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist display data from database on selecting option of dropdownlist Jsp Query run command prompt from jsp program question for c++ please help me how to set up Netbeans for JSP 3 dropdown list from the database using JSP autocompletion in textfield fetching from database in jsp openning the pdf or doc file in same jsp EXT JS tt need coding JSp session time out how to display values from database into table using jsp how to set the class path variable in tomcat ? need help please online examination system mini project problem in writing coding. Please help me. How to read the body content of custom tag? need help...................please please help me jsp coding please. help me image upload Assertions I want to store the value of local variable into Global variable how to create customise shortcut keys in jsp?

Ads

 
Advertisement null

Ads