<%@ page import="java.io.*" %> <% String cart=null; cart=(String) session.getAttribute("cart"); //out.print("Cart : "+cart); if (cart==null || cart.equals(null)) { //out.print("A"); String filepath; filepath = application.getRealPath("/"); FileReader fr = new FileReader(filepath + "file2.txt"); BufferedReader br = new BufferedReader(fr); String s; String str = ""; int intsource=0; while((s=br.readLine()) != null ) { str=s; } intsource = Integer.parseInt(str); intsource +=1; String source =""; source = String.valueOf(intsource); java.io.FileWriter f1 = new java.io.FileWriter(filepath + "file2.txt"); f1.write(source); //out.println("Session:" + source); f1.close(); session.setAttribute("cart",source); } %> Mahek's Cooking Classes
<%@ page import="javax.servlet.*" %> <%@ page import="javax.servlet.http.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <%@ page import="java.text.*" %> <%@ page import="javax.naming.NamingException"%> <%@ page import="javax.naming.InitialContext"%> <%@ page import="javax.sql.DataSource"%> <% Connection dbCon = null; PreparedStatement statshopcat = null; PreparedStatement statvendors = null; PreparedStatement statoccasion = null; PreparedStatement statoccfeat = null; PreparedStatement statcount = null; PreparedStatement statcountven = null; PreparedStatement statcountocc = null; PreparedStatement statweek = null; PreparedStatement statchocoweek = null; PreparedStatement statrecom = null; PreparedStatement statfeature = null; PreparedStatement stathot = null; PreparedStatement stattest = null; ResultSet rsshopcat = null; ResultSet rsvendors = null; ResultSet rscountven = null; ResultSet rscount = null; ResultSet rsoccasion = null; ResultSet rsoccfeat = null; ResultSet rscountocc = null; ResultSet rsweek = null; ResultSet rschocoweek = null; ResultSet rsfeature = null; ResultSet rshot = null; ResultSet rstest = null; //ResultSet rsrecom = null; //String cat = null; //String subcat = null; String strshopcat="select * from catvendor"; String strvendors="select * from vendordetail"; String stroccasion="select * from occasion"; String stroccfeat="select * from occasion where approved = ? order by occasiondate desc"; String strcount="select count(*) as strcount from catvendor"; String strcountven="select count(*) as strcount from catvendor"; String strcountvendor="select count(*) as strcount from vendordetail"; String strcountocc="select count(*) as strcount from occasion"; String strweek="select * from proddetails where featured=?"; String str="select * from proddetails where featured=?"; String strchocoweek="select * from chocolates where chocooftheweek=?"; //String strrecom="select * from proddetails where recommended=?"; String strfeatures ="select * from vendorproduct where approve=? and feature = ?"; String strhot ="select * from vendorproduct where approve=? and hotproduct = ?"; String strtest ="select * from testimonials where approved=?"; int catid=0; int count=0; int countocc=0; int countven=0; String fl="Y"; String feature="yes"; String chocooftheweek="yes"; String approved="yes"; try { //javax.naming.Context initialContext = new javax.naming.InitialContext(); //javax.naming.Context envContext = (javax.naming.Context) initialContext.lookup("java:/comp/env"); //javax.sql.DataSource dataSource = (javax.sql.DataSource) envContext.lookup("jdbc/mssql"); //dbCon = dataSource.getConnection(); Class.forName("com.mysql.jdbc.Driver").newInstance(); //dbCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/maheks_mahek","maheks","mahak"); ServletContext ctx = getServletContext(); String url=ctx.getInitParameter("url"); String user=ctx.getInitParameter("user"); String pw=ctx.getInitParameter("password"); dbCon = DriverManager.getConnection(url,user,pw); statfeature=dbCon.prepareStatement(strfeatures); stathot=dbCon.prepareStatement(strhot); stattest=dbCon.prepareStatement(strtest); stathot.setString(1,feature); stathot.setString(2,feature); rshot=stathot.executeQuery(); statfeature.setString(1,feature); statfeature.setString(2,feature); rsfeature=statfeature.executeQuery(); stattest.setString(1,approved); rstest=stattest.executeQuery(); statshopcat=dbCon.prepareStatement(strshopcat); rsshopcat=statshopcat.executeQuery(); statcount=dbCon.prepareStatement(strcount); statcountven=dbCon.prepareStatement(strcountvendor); rscountven=statcountven.executeQuery(); rscount=statcount.executeQuery(); statoccasion=dbCon.prepareStatement(stroccasion); rsoccasion=statoccasion.executeQuery(); statcountocc=dbCon.prepareStatement(strcountocc); rscountocc=statcountocc.executeQuery(); statvendors=dbCon.prepareStatement(strvendors); rsvendors=statvendors.executeQuery(); if (rscount.next()) { count = rscount.getInt("strcount"); //out.println(""); } if (rscountocc.next()) { countocc = rscountocc.getInt("strcount"); //out.println(""); } if (rscountven.next()) { countven = rscountven.getInt("strcount"); //out.println(""); } %>
" + count + "" + countocc + "" + count + "
 
 
Search for products
By category : Item Id :
By Occasion : Price Range :
From
By Vendor :  
To
Keyword :    
 
or browse all products
   
<% statoccfeat=dbCon.prepareStatement(stroccfeat); statoccfeat.setString(1,approved); rsoccfeat=statoccfeat.executeQuery(); %>
Forthcoming Occasions
<% DateFormat format; String datestr=null; while (rsoccfeat.next()) { if(rsoccfeat.getDate("occasiondate").equals(null)){ datestr = "Date Not Entered"; } else { java.util.Date date2 = rsoccfeat.getDate("occasiondate"); //java.util.Date date1 = new java.util.Date(time); format = DateFormat.getDateInstance(2); datestr = format.format(date2); } %> <%=rsoccfeat.getString("occasion")%> : <%=datestr%>
<% } %>
<% for (int i=1;i<=3; i++) { if(rsfeature.next()) { %> <% } } %>
Featured products
Rs. <%=rsfeature.getString("costprice")%>
 
 
Hot products
 
List our vendors
 
 
Testimonials
 
<% if (rstest.next()) { %>

<%=rstest.getString("postedby")%>
<%=rstest.getString("description")%>...

<% } else { out.print("No records found!"); } %>
 
 
© 2001-2007 Mahek’s Cooking Classes. | Web design by livepages  
<% } catch (java.sql.SQLException e2) { out.println(e2.toString()); } catch (Exception e) { out.println("

ERROR!

"); out.println("Error = " + e.getMessage() + "
");
				e.printStackTrace(new java.io.PrintWriter(out));
				out.println("
"); return; } finally { try { if(dbCon != null) dbCon.close(); } catch(SQLException sqle) {} } %>