...

View Full Version : sessions



sher_amf
01-18-2008, 08:50 AM
i dont know how to apply sessions in these
this is so that the user wont just copy paste the link before log in
i have attached it in case you want to download it
http://rapidshare.com/files/84696633/sessions.zip.html

main


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Main Page</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:155px;
height:51px;
z-index:1;
left: 161px;
top: 182px;
}
#Layer2 {
position:absolute;
width:155px;
height:51px;
z-index:2;
left: 322px;
top: 67px;
}
#Layer3 {
position:absolute;
width:160px;
height:52px;
z-index:3;
left: 362px;
top: 182px;
}
#Layer4 {
position:absolute;
width:159px;
height:50px;
z-index:4;
left: 574px;
top: 184px;
}
body {
background-image: url(wallpaper.jpg);
}
#Layer5 {
position:absolute;
width:996px;
height:60px;
z-index:5;
left: 7px;
top: 30px;
}
.style1 {
font-family: "Times New Roman", Times, serif;
font-size: 36px;
font-weight: bold;
}
#Layer6 {
position:absolute;
width:534px;
height:82px;
z-index:6;
top: 292px;
left: 3px;
}
#Layer7 {
position:absolute;
width:173px;
height:49px;
z-index:7;
left: 771px;
top: 184px;
}
-->
</style>
</head>

<body>
<div id="Layer7"><a href="stocks.jsp"><img src="enterstock.gif" width="150" height="48" border="0" /></a></div>
<div class="style1" id="Layer5">
<p>ONLINE PORTFOLIO TRACKING SYSTEM</p>
<p><img src="border.jpg" width="982" height="24" /></p>
</div>
<div id="Layer1"><a href="buy.jsp"><img src="BUY2.gif" width="150" height="48" border="0" /></a></div>
<div id="Layer3"><a href="sell.jsp"><img src="SELL2.gif" width="150" height="48" border="0" /></a></div>
<div id="Layer4"><img src="view.gif" width="150" height="48" /></div>
<div id="Layer6"><a href="www.pse.com.ph"><img src="pse.jpg" width="531" height="64" border="0" /></a></div>
</body>
</html>


log


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:155px;
height:51px;
z-index:1;
left: 163px;
top: 135px;
}
#Layer2 {
position:absolute;
width:155px;
height:51px;
z-index:2;
left: 322px;
top: 67px;
}
#Layer3 {
position:absolute;
width:160px;
height:52px;
z-index:3;
left: 372px;
top: 136px;
}
#Layer4 {
position:absolute;
width:159px;
height:50px;
z-index:4;
left: 586px;
top: 136px;
}
body {
background-image: url(wallpaper.jpg);
}
#Layer5 {
position:absolute;
width:996px;
height:60px;
z-index:5;
left: 7px;
top: 30px;
}
.style1 {
font-family: "Times New Roman", Times, serif;
font-size: 36px;
font-weight: bold;
}
#Layer6 {
position:absolute;
width:534px;
height:82px;
z-index:6;
top: 244px;
}
#Layer7 {
position:absolute;
width:326px;
height:117px;
z-index:6;
left: 39px;
top: 170px;
}
#Layer8 {
position:absolute;
width:200px;
height:115px;
z-index:7;
left: 450px;
top: 156px;
}
-->
</style>
</head>

<body>
<div class="style1" id="Layer5">
<p>ONLINE PORTFOLIO TRACKING SYSTEM</p>
<p><img src="border.jpg" width="982" height="24" /></p>
</div>
<div id="Layer7">
<form action = "checklog.jsp" method= "post">
<p><strong>Username:
<input type="text" name="user" />
</strong></p>
<p><strong>Password:</strong>
<input type="password" name="pass" />
</p>
<label></label>
<div align="center">
<input name="Log in" type="submit" id="Log in" value="Log in" />
</div>
<p>&nbsp;</p>
</form>
</div>
<div id="Layer8"><img src="stocl.jpg" width="498" height="252" /></div>
</body>
</html>


check


<html>
<body>

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

<%
try {
Connection con;
Statement stmt;
ResultSet rs;
String username = request.getParameter("user");
String password = request.getParameter("pass");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:sherwin","","");
stmt = con.createStatement();

rs = stmt.executeQuery("select * from account");
while (rs.next())
{
String tmpUser= rs.getString("user");
String tmpPass= rs.getString("pass");

if (username.equals(tmpUser) && password.equals(tmpPass))
{session.setAttribute("username", tmpUser);
response.sendRedirect("main.jsp");}
}
response.sendRedirect("log.jsp");
con.close();
} catch (Exception e){
System.out.println("SQL Exception : " + e.getMessage());
}
%>

</body>
</html>

sher_amf
01-18-2008, 11:08 AM
changed this
rs = stmt.executeQuery("INSERT INTO stocks (broker,stock,value,qty) VALUES ('"+broker+"','"+stock+"','"+value+"','"+qty+"')");

bhargavkumar_b
01-19-2008, 12:18 PM
Hi,
This is in reply that u have raised a query about sessions problem. U can try with "instanceOf" object of "request" object , means u can redirect to any page if that request is the object of your original session.

Thanks and regards
BhargavKumar.B



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum