<%@ page import="java.sql.*" %> <%@ page import="java.util.*" %> <%@ page import="java.text.*" %> <% int intuid=0; //String insertstr ="INSERT INTO recipelandingpage (id,title,desc1,img,approved) values(?,?,?,?,?)"; Connection dbCon = null; PreparedStatement stat = null; PreparedStatement stat1 = null; PreparedStatement statsearch = null; PreparedStatement statcount = null; ResultSet rs = null; ResultSet rssearch = null; ResultSet rscount = null; String selectstr = "Select * from subcategory"; String strsearch = "select * from vendorproduct where approve =? "; String strcount ="select count(*) as strcount from vendorproduct where approve=?"; String strsearch1=null; String title = null; String desc = null; String approved = "yes"; //String middletext= null; //String endtext = null; //String tiptext = null; //String approved = null; try { //out.println("Approved :" + approved); //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"); //dbCon = DriverManager.getConnection("jdbc:mysql://localhost:3306/myrecipe","root",""); ServletContext ctx = getServletContext(); String url=ctx.getInitParameter("url"); String user=ctx.getInitParameter("user"); String pw=ctx.getInitParameter("password"); String[] catarr={}; String[] occarr={}; String[] venarr={}; dbCon = DriverManager.getConnection(url,user,pw); boolean catpresent=false; boolean occpresent=false; boolean venpresent=false; boolean keypresent=false; boolean itempresent=false; boolean pfrompresent=false; boolean ptopresent=false; String cat =request.getParameter("category123"); String occasion =request.getParameter("occasiontxt"); if (occasion==null) { occasion=""; } String vendor =request.getParameter("vendortxt"); if (vendor==null) { vendor=""; } String keywords =request.getParameter("keywordtxt"); if (keywords==null) { keywords=""; } String itemid =request.getParameter("itemid"); if (itemid==null) { itemid=""; } int pricefrom = 0; int priceto = 0; //out.print("From "+request.getParameter("pricefrom")); if (request.getParameter("pricefrom")=="" || request.getParameter("pricefrom")==null) { } else { pricefrom = Integer.parseInt(request.getParameter("pricefrom")); } //out.print("To "+request.getParameter("priceto")); if (request.getParameter("priceto")=="" || request.getParameter("priceto")==null) {} else { priceto = Integer.parseInt(request.getParameter("priceto")); } stat = dbCon.prepareStatement(selectstr); //statsearch = dbCon.prepareStatement(strsearch); //statsearch.setString(2,"Utilities"); int catid=1; //statsearch.setInt(2,catid); //rssearch = statsearch.executeQuery(); rs=stat.executeQuery(); //out.println(request.getParameter("category123")); if (cat==null || cat=="") { cat=""; //out.print("Blank Category"); catpresent=false; } else { catpresent=true; strsearch=strsearch+" and cat In "; strcount=strcount+" and cat In "; //out.print(strsearch); } //out.print(strsearch); StringTokenizer Tok = new StringTokenizer(cat,","); StringTokenizer Tokocc = new StringTokenizer(occasion,","); //out.print("K"); StringTokenizer Tokven = new StringTokenizer(vendor,","); String catsearch=""; int catno=0; int occno=0; int venno=0; int keywordsno=0; int itemidno=0; int pfromno=0; int ptono=0; int arrsize = Tok.countTokens(); int occarrsize = Tokocc.countTokens(); int venarrsize = Tokven.countTokens(); catarr = new String[arrsize]; occarr = new String[occarrsize]; //out.print("OCCARRSize : "+occarrsize); venarr = new String[venarrsize]; while (Tok.hasMoreElements()) { if (catno==0){ strsearch=strsearch+"("; strcount=strcount+"("; } catno=catno+1; catarr[catno-1] = (String) Tok.nextElement(); } for (int ii=1; ii<=catno; ii++) { if (ii!=1) { strsearch=strsearch+","; strcount=strcount+","; } strsearch=strsearch+"?"; strcount=strcount+"?"; } if(catno!=0) { strsearch=strsearch+")"; strcount=strcount+")"; } //out.print("Search"+strsearch); strsearch1=strsearch; if (occasion.equals(null) || occasion.equals("")) { //out.print("Blank Occasion"); occpresent=false; } else { occpresent=true; if (catpresent==false) { strsearch=strsearch+" and occasion In "; strcount=strcount+" and occasion In "; } else { strsearch=strsearch+" or occasion In "; strcount=strcount+" or occasion In "; //out.print(strsearch); } } //out.print(occpresent); while (Tokocc.hasMoreElements()) { if (occno==0){ strsearch=strsearch+"("; strcount=strcount+"("; } occno=occno+1; occarr[occno-1] = (String) Tokocc.nextElement(); } for (int kk=1; kk<=occno; kk++) { if (kk!=1) { strsearch=strsearch+","; strcount=strcount+","; } strsearch=strsearch+"?"; strcount=strcount+"?"; } if(occno!=0) { strsearch=strsearch+")"; strcount=strcount+")"; } // for vendor if (vendor.equals(null) || vendor.equals("")) { //out.print("Blank Occasion"); venpresent=false; } else { venpresent=true; if (occpresent==false && catpresent==false) { strsearch=strsearch+" and vendorid In "; strcount=strcount+" and vendorid In "; } else { strsearch=strsearch+" or vendorid In "; strcount=strcount+" or vendorid In "; //out.print(strsearch); } } while (Tokven.hasMoreElements()) { if (venno==0){ strsearch=strsearch+"("; strcount=strcount+"("; } venno=venno+1; venarr[venno-1] = (String) Tokven.nextElement(); } for (int mm=1; mm<=venno; mm++) { if (mm!=1) { strsearch=strsearch+","; strcount=strcount+","; } strsearch=strsearch+"?"; strcount=strcount+"?"; } if(venno!=0) { strsearch=strsearch+")"; strcount=strcount+")"; } //out.print("
"+strsearch); if (keywords.equals(null) || keywords.equals("")) { //out.print("Blank Occasion"); keypresent=false; } else { keypresent=true; keywordsno=1; //venpresent=true; if (occpresent==false && catpresent==false) { strsearch=strsearch+" and prodtitle like ? "; strcount=strcount+" and prodtitle like ? "; } else { strsearch=strsearch+" or prodtitle like ? "; strcount=strcount+" or prodtitle like ? "; //out.print(strsearch); } } if (itemid.equals(null) || itemid.equals("")) { //out.print("Blank Occasion"); itempresent=false; } else { itempresent=true; itemidno=1; //venpresent=true; if (occpresent==false && catpresent==false && keypresent==false) { strsearch=strsearch+" and prodrefno like ? "; strcount=strcount+" and prodrefno like ? "; } else { strsearch=strsearch+" or prodrefno like ? "; strcount=strcount+" or prodrefno like ? "; //out.print(strsearch); } } if (priceto==0) { if (pricefrom==0) { //out.print("Blank Occasion"); pfrompresent=false; } else { pfromno=1; pfrompresent=true; if (occpresent==false && catpresent==false && keypresent==false) { strsearch=strsearch+" and costprice >= ? "; strcount=strcount+" and costprice >= ? "; } else { strsearch=strsearch+" and costprice >= ? "; strcount=strcount+" and costprice >= ? "; //out.print(strsearch); } } } else { pfromno=1; } if (priceto==0) { //out.print("Blank Occasion"); ptopresent=false; } else { ptono=1; ptopresent=true; if (occpresent==false && catpresent==false && keypresent==false && pfrompresent==false) { strsearch=strsearch+" and costprice between ? and ? "; strcount=strcount+" and costprice between ? and ? "; } else { strsearch=strsearch+" and costprice between ? and ? "; strcount=strcount+" and costprice between ? and ? "; //out.print(strsearch); } } //out.print(strsearch); statsearch=dbCon.prepareStatement(strsearch); statcount=dbCon.prepareStatement(strcount); statsearch.setString(1,approved); statcount.setString(1,approved); for(int jj=0; jj"); statsearch.setString(ll+catno+2,occarr[ll]); statcount.setString(ll+catno+2,occarr[ll]); } //out.print("Hi......"); for(int nn=0; nn"+strsearch); //out.print("
"+strcount); if (keywordsno!=0) { keywords="%"+keywords+"%"; //out.print(keywords); statsearch.setString(venno+occno+catno+2,keywords); statcount.setString(venno+occno+catno+2,keywords); } if (itemidno!=0) { itemid="%"+itemid+"%"; //out.print(keywords); statsearch.setString(keywordsno+venno+occno+catno+2,itemid); statcount.setString(keywordsno+venno+occno+catno+2,itemid); } if (pfromno!=0) { //pricefrom="%"+pricefrom+"%"; //out.print(occno+catno+keywordsno+2); statsearch.setInt(itemidno+venno+occno+catno+keywordsno+2,pricefrom); statcount.setInt(itemidno+venno+occno+catno+keywordsno+2,pricefrom); } if (ptono!=0) { //pricefrom="%"+pricefrom+"%"; //out.print(occno+catno+keywordsno+pfromno+2); statsearch.setInt(itemidno+venno+occno+catno+keywordsno+pfromno+2,priceto); statcount.setInt(itemidno+venno+occno+catno+keywordsno+pfromno+2,priceto); } rssearch=statsearch.executeQuery(); rscount=statcount.executeQuery(); //out.print(itemid); %> Mahek's Cooking Classes
 
 
Shopping » Browse  
<% int pagebreak=0; int noofelements = 4; int count = 0; int pageval = 0; int startval =0; int startval1 =0; int pageend =0; int startindx=0; int endindx=0; if (rscount.next()) { count = rscount.getInt("strcount"); //out.println(""); } if ((count % noofelements) == 0 ) { pageval = count / noofelements; //out.println("page1" + (count % noofelements)); } else { pageval = (count / noofelements) + 1; //out.println("page2" + pageval); } //out.println(count); if (request.getParameter("startvalue") != null) startval = Integer.parseInt(request.getParameter("startvalue")); else startval=0; startval1=startval; %>
" + count + "
<% if (count!=0) { %> <% } else { %> <% //out.print("No records found"); } // for paging %> <% // for paging %>
navigate   <% pageend=pageval-1; startindx = startval1 - 2; endindx = startval1 + 2; //out.print(startindx+1); //out.print(endindx+1); if(startval1!= 0) { %> «   <% } else { %>   <% } for (int j=0; j= startindx && j <= endindx) { //out.print(startval1); if (j==startval1) { %> <%=(j+1)%>   <% } else { %> <%=(j+1)%>   <% } } } if(startval1!= pageend) { %> » <% } else { %> <% } %>
No Records Found
 
 
 
<% if (startval==0) { for (int i=1; i<=count; i++) { if( i >= startval && i <= startval + noofelements) { // Display Data if(rssearch.next()) { pagebreak=pagebreak+1; %> <% if (pagebreak % 2!=0) { %> <% if (rssearch.isLast()) { %> <% } %> <% } %> <% if (pagebreak % 2==0) { %> <% } } } } } else { startval = startval * noofelements; //out.println("start" +startval); for (int j=1; j<=count; j++) { if(rssearch.next()) { if ( j > startval && j <= startval + noofelements) { pagebreak=pagebreak+1; //Display Data %> <% if (pagebreak % 2!=0) { %> <% if (rssearch.isLast()) { %> <% } %> <% } %> <% if (pagebreak % 2==0) { %> <% } } } } } //out.println(""); //out.println(""); %>
Anniversary
<%=rssearch.getString("prodtitle")%>
','PasswordRetrievalPage','width=300,height=450,top=200,left=0');">" border="0" width="80">
<% String desc1 = rssearch.getString("description"); int lendesc=desc1.length(); if (lendesc>100) { desc1=desc1.substring(1,100); } out.print(desc1+"..."); %>
Our Price
Rs.<%=rssearch.getString("costprice")%>
 
&add=1" > &startvalue=0">
click thumbnail for large view
 
 
  
 
<%=rssearch.getString("prodtitle")%>
','PasswordRetrievalPage','width=300,height=450,top=200,left=0');">" border="0" width="80">
<% String desc1 = rssearch.getString("description"); int lendesc=desc1.length(); if (lendesc>100) { desc1=desc1.substring(1,100); } out.print(desc1+"..."); %>
Our Price
Rs.<%=rssearch.getString("costprice")%>
 
&add=1" > &startvalue=0">
click thumbnail for large view
 
 
  
 
Go To Page:
 
 
 
 
 
<% if (count!=0) { %> <% } else { %> <% //out.print("No records found"); } // for paging %> <% // for paging %>
navigate   <% pageend=pageval-1; startindx = startval1 - 2; endindx = startval1 + 2; //out.print(startindx+1); //out.print(endindx+1); if(startval1!= 0) { %> «   <% } else { %>   <% } for (int j=0; j= startindx && j <= endindx) { //out.print(startval1); if (j==startval1) { %> <%=(j+1)%>   <% } else { %> <%=(j+1)%>   <% } } } if(startval1!= pageend) { %> » <% } else { %> <% } %>
 
Send gift items to India . All major credit cards accepted.
Free shipping all over india, normally
 
 
 
© 2001-2007 Mahek’s Cooking Classes. | Web design by livepages  
<% } catch (java.sql.SQLException e2) { out.println(e2.toString()); } catch (java.lang.NumberFormatException e3) { out.println(e3.toString()); e3.printStackTrace(new java.io.PrintWriter(out)); } 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) {} } %>