Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


senthil
jsp sessions
1 Answer(s)      6 years and 5 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

May 14, 2008 at 6:51 PM


Hi

This is login page code,

<html>
<head>
<title>Insert into database</title>

</head>

<body>

<table border="1" width="50%" bgcolor="pink">
<tr>
<td width="100%">
<form method="POST" action="loginAction.jsp">

<h2 align="center">login page</h2>
<table border="1" width="100%">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><input type="text" name="userid" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Password:</b></td>
<td width="50%"><input type="password" name="password" size="20"/> </td>
</tr>

</table>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>

</form>
</td>
</tr>
</table>

</body>

</html>
------------------------------

login action code,

<%@ page language="java" import="java.sql.*" %>

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String user=request.getParameter("userid");
String pass=request.getParameter("password");

ResultSet rs=st.executeQuery("select userid,password from login");
while(rs.next()) {
String userid =rs.getString(1);
String passw=rs.getString(2);
if(user.equals(userid) && pass.equals(passw)) {
session.setAttribute("user",user);

%>
<jsp:forward page="registrationForm.jsp" />
<%}
else
out.println("Login Failed,Please try Againe");
%>

<%
}
}catch(Exception e1){}
}
catch (Exception e){
e.printStackTrace();
}

%>

---------------------------

this is logout code,

<%@ page language="java" %>

<%
session.removeAttribute("user");
session.invalidate();
response.sendRedirect("loginForm.jsp");
%>




Related Tutorials/Questions & Answers:
jsp sessions - JSP-Servlet
jsp sessions  Hi, i am JSP sessions example and code.  using SessenListners
jsp sessions - JSP-Servlet
jsp sessions  hai deepak this is senthil i have a query that is in my project home page there is a login i want to track the users who are all logged with date and time including logout time i tried this code using beans
Advertisements
sessions - JSP-Servlet
sessions  how can we maintain sessions and using that particular session can we perform diffrent bussiness logic of any particular user
sessions - JSP-Servlet
to : http://www.roseindia.net/jsp/jsp-form-session.shtml Thanks  
sessions
sessions  how to create a session for jsp to servlet
Sessions
Sessions  how to set JSESSIONID in JSP login page...   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/jspsession/ http://www.roseindia.net/jsp/jspsessions.shtml Thanks
sessions
cookies at in JSP. In the same manner you can it in servlet. Thanks
Sessions in servlets
Sessions in servlets  What is the use of sessions in servlets?   The servlet HttpSession interface is used to simulate the concept that a person's visit to a Web site is one continuous series of interactions
sessions management
sessions management  I have a problem with the session management of my applcation deployed in tomcat. in fact, my application allows only one session to a login / password given. I then add in the database a flag for each user
php garbage collection sessions - PHP
php garbage collection sessions  i wanted to know more about the php garbage collection sessions.. how can i create and hold
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions... Sessions and Transactions are created using Spring-AOP when the control flows
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions... Sessions and Transactions are created using Spring-AOP when the control flows
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions... Sessions and Transactions are created using Spring-AOP when the control flows
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions... Sessions and Transactions are created using Spring-AOP when the control flows
Creating Hibernate Sessions and Transactions through Spring - AOP .
Creating Hibernate Sessions and Transactions through Spring - AOP .  Hi, I am facing some technical issues in creating the Hibernate Sessions... Sessions and Transactions are created using Spring-AOP when the control flows
Working with sessions
Working with sessions          This JSP Tutorial shows you how to track the session between different JSP pages. In any web
Manage end-user state and understand performance tradeoffs of using HTTP sessions
performance tradeoffs of using HTTP sessions Prev Chapter 2. ... sessions A session is a series of requests.... Sessions allow applications running in a Web container to keep track
JSP
JSP  what are the different scopes an object can have in a jsp page   JSP Scope Variables: Page scope-It makes the data available... available across sessions and/or users and across pages. For examples,please visit
java - JSP-Servlet
java  How to use sessions in JSP pages? I am using the following code for sessions in jsp pages to send and recieve sessions but i am not able... for more information: http://www.roseindia.net/jsp/jspsession/SessionLess.shtml
Programmig in JSP - JSP-Servlet
it goes to a JSP page which display current date and time and by clicking on link for schedule of your practical sessions of say,PQRSmodule another JSP page...Programmig in JSP  Write a JSP Program, which displays a web page
jsp and servlet
jsp and servlet  hello friends just want to create a jsp page... jdbc .and how to use sessions for users.   Please visit the following links: http://www.roseindia.net/jsp/loginbean.shtml http://www.roseindia.net
jsp - Java Beginners
to the details.iam id value put the sessions but iam not geting plz help me   Hi...; 3)editClient.jsp: For sessions,please visit the following link: http://www.roseindia.net/jsp/SessionAttribute.shtml http
Use Of Form Bean In JSP
Use Of Form Bean In JSP      ... about the procedure of handling sessions by using Java Bean. This section provides...;jsp:useBean id="user" class="roseindia.net.UserData" scope
jsp
jsp  how to include two jsp page
JSP
what is JSP forward tag for  what is JSP forward tag for   It forwards the current request to another JSP page. Below is the syntax for the same:- <jsp:forward page="...url..." /> We can also forward parameter
Jsp
Jsp  Can I implement interface in jsp
jsp
jsp  how to create jsp page
JSP
JSP  How to run jsp program in eclipse
jsp
jsp  how jsp translated into servlets
Advertisements
 

 

 

DMCA.com