| | |
oracle session in jsp pages
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 4
Reputation:
Solved Threads: 0
Hello,
I have developed a web based application using jsp and connection as Oracle 9i database. The problem encountered is that whenever I am opening any jsp pages, a session is being created in the database which even after being killed did not disappear. In fact it should be that when i login to my site that a session be created but that is not the case. whenever i am opening the site a session is being created even though i did not login. I am sending u the code of one of my jsp page, can u plz verify the codes and let me know if i should add something which does not allow a session to create after opening the site.
Thank you.
********************************************
I have developed a web based application using jsp and connection as Oracle 9i database. The problem encountered is that whenever I am opening any jsp pages, a session is being created in the database which even after being killed did not disappear. In fact it should be that when i login to my site that a session be created but that is not the case. whenever i am opening the site a session is being created even though i did not login. I am sending u the code of one of my jsp page, can u plz verify the codes and let me know if i should add something which does not allow a session to create after opening the site.
Thank you.
********************************************
JSP Syntax (Toggle Plain Text)
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <% response.setHeader("Cache-Control","no-cache"); %> <%@ include file ="dbcon.jsp"%> <% String Butt = request.getParameter("sub"); String Logins=request.getParameter("lname232"); String PASS=request.getParameter("lpass232"); String username = ""; String Messa=""; if (Butt !=null){ String selT=request.getParameter("typeofs"); int compc=selT.compareTo("Consultancy"); int compsu=selT.compareTo("Supplier"); int compse=selT.compareTo("Services"); int compw=selT.compareTo("Work"); if(compc==0) { String query = "SELECT * FROM TBL_PPO_USERS where USERNAME ='"+ Logins +"' and PASSWORD='"+ PASS +"'"; ResultSet resultSet = statement.executeQuery(query); if (resultSet.next()){ username = resultSet.getString("USERNAME"); session.setAttribute("username",username); if (resultSet != null) { resultSet.close(); resultSet = null; } if (statement != null) { statement.close(); statement = null; } if (connection != null) { connection.close(); connection = null; } response.sendRedirect("redoregconsul_Edit.jsp"); }else{ Messa=("Error login/password !"); } } if(compsu==0) { String query = "SELECT * FROM TBL_PPO_SUPPLIER where USERNAME ='"+ Logins +"' and PASSWORD='"+ PASS +"'"; ResultSet resultSet = statement.executeQuery(query); if (resultSet.next()){ username = resultSet.getString("USERNAME"); session.setAttribute("username",username); if (resultSet != null) { resultSet.close(); resultSet = null; } if (statement != null) { statement.close(); statement = null; } if (connection != null) { connection.close(); connection = null; } response.sendRedirect("redoregsupp_Edit.jsp"); }else{ Messa=("Error login/password !"); } } if(compse==0) { String query = "SELECT * FROM TBL_PPO_SERVICES where USERNAME ='"+ Logins +"' and PASSWORD='"+ PASS +"'"; ResultSet resultSet = statement.executeQuery(query); if (resultSet.next()){ username = resultSet.getString("USERNAME"); session.setAttribute("username",username); if (resultSet != null) { resultSet.close(); resultSet = null; } if (statement != null) { statement.close(); statement = null; } if (connection != null) { connection.close(); connection = null; } response.sendRedirect("redoregserv_Edit.jsp"); }else{ Messa=("Error login/password !"); } } if(compw==0) { String query = "SELECT * FROM TBL_PPO_WORK where USERNAME ='"+ Logins +"' and PASSWORD='"+ PASS +"'"; ResultSet resultSet = statement.executeQuery(query); if (resultSet.next()){ username = resultSet.getString("USERNAME"); session.setAttribute("username",username); if (resultSet != null) { resultSet.close(); resultSet = null; } if (statement != null) { statement.close(); statement = null; } if (connection != null) { connection.close(); connection = null; } response.sendRedirect("redoregwork_edit.jsp"); }else{ Messa=("Error login/password !"); } } } %> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Supplier Login</title> <META content="text/html; charset=iso-8859-1" http-equiv=Content-Type> <LINK rel=stylesheet type=text/css href="style/styles.css"> <link href="style/styles1.css" rel="stylesheet" type="text/css" /> </head> <BODY bgColor=#e9e9e9> <form method="POST" action="index.jsp"> <TABLE border=0 cellSpacing=0 cellPadding=0 width=780 align=center height="100%"> <TBODY> <TR> <TD height=31> <TABLE border=0 cellSpacing=0 cellPadding=0 width=779 align=center> <TBODY> <TR> <TD height="31" background="image/2bt1a.gif" class="header"><div align="right"> <a href="http://ppo.gov.mu">Home</a> | <a href="http://www.gov.mu/portal/site/pposite/menuitem.1aa44665158181fbe8633010a0208a0c/" target="_blank">Contacts Us</a> </div></TD> </TR></TBODY></TABLE></TD></TR> <TR> <TD height=133><img src="image/2logob.gif" width="227" height="130"><img src="image/2img1b.jpg" width="550" height="130" /></TD> </TR> <TR> <TD height="2"></TD> </TR> <TR> <TD height=8 vAlign=top> <TABLE width=779 height=24 border=0 align=center cellPadding=0 cellSpacing=0 background="Contact1_files/menubg.gif"> <TBODY> <TR> <TD background="image/menubg.gif"><span class="topmenu"><strong><a href="supplierlogin.htm"> </a></strong></span></TD> </TR></TBODY></TABLE></TD></TR> <TR> <TD vAlign=top> <TABLE border=0 cellSpacing=1 cellPadding=3 width=779 bgColor=#cccccc align=center height="100%"> <TBODY> <TR> <TD bgColor=#ffffff vAlign=top> <TABLE border=0 cellSpacing=0 cellPadding=20 width="100%" > <TBODY> <TR> <TD vAlign=top align=left><SPAN class=txt1></SPAN> <TABLE border=0 cellSpacing=10 cellPadding=2 width="100%" align=center> <TBODY> <TR> <TD vAlign=top align=left> <P> <img src="image/bullet.gif" width="22" height="9"> <span class="title">Accessing Supplier Database</span></P> <div align="center"><%=Messa%></div> <table width="450" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC"> <tr> <td><table width="450" border="0" align="center" cellpadding="5" cellspacing="0"> <tr > <td colspan="2" bgcolor="#CCCCCC" ><div align="left" class="logtitle"><img src="image/keys.jpg" width="18" height="30" align="absmiddle"> Supplier Login </div></td> </tr> <tr> <td valign="top" class="text1" > </td> <td valign="top" class="text1"> </td> </tr> <tr> <td width="159" valign="top" class="text1" ><div align="right">User Name :</div></td> <td width="320" valign="top" class="text1"> <input type="text" name="lname232" width="200" id="lname232"> </td> </tr> <tr> <td valign="top" class="text1"><div align="right">Password:</div></td> <td valign="top" class="text1"><input type="password" name="lpass232" width="200" id="lpass232"/></td> </tr> <tr> <td valign="top" ><div align="right" class="text1">Type of Service:</div></td> <td valign="top" ><select name="typeofs" size="1" id="typeofs"> <option value="Consultancy">Consultancy</option> <option value="Services">Services</option> <option value="Supplier">Supplier</option> <option value="Work">Work</option> </select></td> </tr> <tr> <td valign="top" > </td> <td valign="top" > <div align="right"> <input type="submit" name="sub" value="Sign in" id="sub"> </div></td> </tr> </table></td> </tr> </table> <p> </p> <p> </p> </TD> </TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD height=8> <TABLE border=0 cellSpacing=0 cellPadding=0 width=779 align=center height=8> <TBODY> <TR> <TD vAlign=center align=middle><IMG src="Contact1_files/spacer.gif" width=1 height=1></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD height=20> <TABLE border=0 cellSpacing=0 cellPadding=0 width=779 align=center> <TBODY> <TR> <TD width=620 height="20" background=image/2bt1a.gif><SPAN class=footer> Copyright © Procurement Policy Office </SPAN></TD> </TR></TBODY></TABLE></TD></TR></TBODY></TABLE> <% if (statement != null) { statement.close(); statement = null; } if (statement2 != null) { statement2.close(); statement2 = null; } if (connection != null) { connection.close(); connection = null; } %> </form></BODY></HTML>
Last edited by peter_budo; Jul 3rd, 2009 at 8:53 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
You need to separate your presentation from business logic. In simple terms JSP should only present what ever data and call upon servlet to do computation like connecting with database. You may want to have look on this post how to approach your task
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- adding more variables in session : jsp (JSP)
- i want source code for maintaining session in a jsp (JSP)
- How to connect Oracle database from JSP page (Java)
- pass bean property name across JSP pages (JSP)
- images not displaying in JSP pages! (Java)
- how to connect oracle 8i database with jsp page (JSP)
- JSP pages not showing up (JSP)
Other Threads in the JSP Forum
- Previous Thread: I can't insert data into database
- Next Thread: jasper exception?
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






