diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.class b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.class new file mode 100644 index 0000000..2cbf66d Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.java b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.java new file mode 100644 index 0000000..8032eca --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Cart.java @@ -0,0 +1,171 @@ +// Cart +package obs; +import java.util.*; +import java.sql.*; +import obs.*; +import javax.ejb.*; +import javax.naming.*; +import obs.order.*; + + + + +public class Cart +{ + ArrayList items = new ArrayList(); + + public Item find(String isbn) + { + Iterator itr = items.iterator(); + Item itm; + while ( itr.hasNext()) + { + itm = (Item) itr.next(); + if ( itm.getIsbn().equals(isbn)) + { + return itm; + } + } // end of while + + return null; + } + + // adds an item if not already existing + // otherwise add 1 to qty + public void addItem(String isbn ) + { + //check whether isbn is already present + Item item = find(isbn); + if ( item != null) + item.addQty(1); + else + { + // get detais from Books tables + + Connection con =null; + obs.User user = new obs.User(); + try + { + con = user.getConnection(); + PreparedStatement ps = con.prepareStatement("select title,price from books where isbn = ? "); + ps.setString(1,isbn); + + ResultSet rs = ps.executeQuery(); + if ( rs.next()) + { + item = new Item(isbn, rs.getString(1), rs.getInt(2) ); + items.add(item); + } + + rs.close(); + ps.close(); + + } + catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + finally + { + try {con.close();} catch(Exception ex) {} + } + } // end of else + } + + public ArrayList getItems() + { return items; } + + public void removeItem(String isbn) + { + Item item = find(isbn); + if ( item != null) + items.remove(item); + } // end or removeItem + + public void clearAll() + { + items.clear(); + } + + public void updateQty(String isbn, int qty) + { + Item item = find(isbn); + if ( item != null) + item.setQty(qty); + } // end of updateQty() + + + public String finalizeOrder(int userid) + { + + try + { + Context ctx = getInitialContext(); + // get access to bean + + OrderHome home = (OrderHome) ctx.lookup("obs.order"); + Order order = home.create(); + + String id= order.addOrder(userid,items); + return id; + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + return null; + + } + + } // end of finalizeOrder + + + + public boolean cancelOrder(int ordid) + { + + try + { + Context ctx = getInitialContext(); + // get access to bean + + OrderHome home = (OrderHome) ctx.lookup("obs.order"); + Order order = home.create(); + + return order.cancelOrder(ordid); + + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + return false; + + } + + + } // end of finalizeOrder + + public Context getInitialContext() + { + + String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory"; + + try + { + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY); + env.put(Context.PROVIDER_URL,"t3://localhost:7001"); + return new InitialContext(env); + } + catch(Exception ex) + { + System.out.println(ex.getMessage()); + return null; + } + + } + +} + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Customer.java b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Customer.java new file mode 100644 index 0000000..8751448 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Customer.java @@ -0,0 +1,200 @@ +// User Bean + +package cs; +import java.sql.*; +import java.util.*; +import javax.naming.*; +import javax.rmi.*; + + + +public class Customer +{ + + + private String custname; + private String password; + private String email; + private String phoneno; + + private Context ctx; + + public Context getJNDIContext() + { + return ctx; + } + + public Customer() + { + ctx = getInitialContext(); + } + + public void setCustname(String custname) + { this.custname = custname; } + + public String getCustname() + { return custname; } + + + public void setPhoneno (String phoneno) + { this.phoneno = phoneno; } + + public String getPhoneno() + { return phoneno; } + + public void setPassword(String password) + { this.password= password; } + + public String getPassword() + { return password; } + + public void setEmail (String email) + { this.email = email; } + + public String getEmail() + { return email; } + + // returns true if uname and pwd are valid + public boolean isValid() + { + Connection con = null; + PreparedStatement ps = null; + try + { + con = getConnection(); + ps = con.prepareStatement("select phoneno, email from customers where custname = ? and pwd= ?"); + ps.setString(1,custname); + ps.setString(2,password); + + ResultSet rs = ps.executeQuery(); + boolean found = false; + + if ( rs.next()) + { phoneno = rs.getString("phoneno"); + email = rs.getString("email"); + found = true; + } + return found; + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + return false; + } + finally + { + clean(con,ps); + } + + } // end of isValid + + public String updatePassword(String newpassword) + { + Connection con = null; + PreparedStatement ps= null; + + try + { + con = getConnection(); + ps = con.prepareStatement("update customers set pwd = ? where custname = ?"); + ps.setString(1,newpassword); + ps.setString(2,custname); + + int cnt = ps.executeUpdate(); + if ( cnt==1 ) + return null; + else + return "Invalid Username!"; + + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + return ex.getMessage(); + } + finally + { + clean(con,ps); + } + + } // end of updatePassword + + public String registerUser() + { + Connection con = null; + PreparedStatement ps = null; + + try + { + con = getConnection(); + ps = con.prepareStatement("insert into customers values (?,?,?,?)"); + ps.setString(1,custname); + ps.setString(2,password); + ps.setString(3,email); + ps.setString(4,phoneno); + ps.executeUpdate(); + return null; + + } + catch(Exception ex) + { + return ex.getMessage(); + } + finally + { clean(con,ps); } + } + + + + + public void clean(Connection con, PreparedStatement ps) + { + try + { if ( ps != null ) ps.close(); + if ( con != null) con.close(); + } + catch(Exception ex) + { System.out.println(ex.getMessage()); } + } + + public Connection getConnection() throws Exception + { + Class.forName("oracle.jdbc.driver.OracleDriver"); + // connect using Thin driver + Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle8i", + "custsup","custsup"); + + return con; + } + + + public Context getInitialContext() + { + + String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory"; + + try + { + Hashtable env = new Hashtable(); + env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY); + env.put(Context.PROVIDER_URL,"t3://localhost:7001"); + return new InitialContext(env); + } + catch(Exception ex) + { + System.out.println(ex.getMessage()); + return null; + } + + } + + +} // end of bean + + + + + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.class b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.class new file mode 100644 index 0000000..70dec1c Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.java b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.java new file mode 100644 index 0000000..286839f --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/Item.java @@ -0,0 +1,43 @@ +// Item class +package obs; +public class Item implements java.io.Serializable +{ + + private String isbn,title; + private int price; + private int qty; + + public Item(String isbn,String title, int price) + { + this.isbn = isbn; + this.title = title; + this.price = price; + this.qty = 1; + } + public String getIsbn() + { + return isbn; + } + + public String getTitle() + { + return title; + } + + public int getQty() + { + return qty; + } + + public void setQty(int qty) + { this.qty = qty; } + + public void addQty(int qty) + { this.qty += qty; } + + public int getPrice() + { + return price; + } +} // end of class + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.class b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.class new file mode 100644 index 0000000..abc3b31 Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.java b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.java new file mode 100644 index 0000000..b97c7c5 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/User.java @@ -0,0 +1,210 @@ +// User Bean + +package obs; +import java.sql.*; +import java.util.*; + + +public class User +{ + private int userid; + private String uname; + private String pwd; + private String email; + private String address; + private String phone; + + private boolean logged = false; + + public int getUserid() + { return userid; } + + public void setUname(String uname) + { this.uname = uname; } + + public String getUname() + { return uname; } + + public void setPwd(String pwd) + { this.pwd= pwd; } + + public String getPwd() + { return pwd; } + + public void setEmail (String email) + { this.email = email; } + + public String getEmail() + { return email; } + + public void setAddress(String address) + { this.address = address; } + + public String getAddress() + { return address; } + + + public void setPhone(String phone) + { this.phone = phone; } + + public String getPhone() + { return phone; } + + + public void login() + { + Connection con = null; + PreparedStatement ps = null; + try + { + con = getConnection(); + ps = con.prepareStatement("select userid,email,phone,address from users where uname = ? and pwd= ?"); + ps.setString(1,uname); + ps.setString(2,pwd); + + ResultSet rs = ps.executeQuery(); + + logged = false; + + if ( rs.next()) + { userid = rs.getInt("userid"); + email = rs.getString("email"); + address = rs.getString("address"); + phone = rs.getString("phone"); + logged = true; + } + + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + } + finally + { + clean(con,ps); + } + + } // end of isValid + + + + public String updateProfile(String newpwd) + { + Connection con = null; + PreparedStatement ps= null; + + try + { + con = getConnection(); + String cmd = "update users set email=?, phone = ? , address =? "; + + if (! newpwd.equals("")) + cmd += " , pwd = '" + newpwd + "'"; + + cmd = cmd + " where userid = ?"; + + ps = con.prepareStatement(cmd); + ps.setString(1,email); + ps.setString(2,phone); + ps.setString(3,address); + ps.setInt(4,userid); + + int cnt = ps.executeUpdate(); + if ( cnt==1 ) + { + if ( ! newpwd.equals("") ) + pwd = newpwd; + return null; + } + else + return "Invalid User. Unable to update profile."; + + } + catch(Exception ex) + { + System.out.println( ex.getMessage()); + return ex.getMessage(); + } + finally + { + clean(con,ps); + } + + } // end of updateProfile + + + + public String registerUser() + { + Connection con = null; + PreparedStatement ps = null; + + try + { + con = getConnection(); + userid = getNextUserid(con); + ps = con.prepareStatement("insert into users values (?,?,?,?,?,?)"); + ps.setInt(1,userid); + ps.setString(2,uname); + ps.setString(3,pwd); + ps.setString(4,email); + ps.setString(5,address); + ps.setString(6,phone); + ps.executeUpdate(); + logged = true; + return null; + } + catch(Exception ex) + { + return ex.getMessage(); + } + finally + { clean(con,ps); } + } + + public boolean isLogged() + { return logged; } + + + public int getNextUserid(Connection con) throws Exception + { + PreparedStatement ps = null; + ps = con.prepareStatement("select nvl( max(userid),0) + 1 from users"); + ResultSet rs = ps.executeQuery(); + rs.next(); + int nextuserid = rs.getInt(1); + rs.close(); + + return nextuserid; + + } + + + public void clean(Connection con, PreparedStatement ps) + { + try + { if ( ps != null ) ps.close(); + if ( con != null) con.close(); + } + catch(Exception ex) + { System.out.println(ex.getMessage()); } + } + + public Connection getConnection() throws Exception + { + Class.forName("oracle.jdbc.driver.OracleDriver"); + // connect using Thin driver + Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle9i", + "obs","obs"); + return con; + } + +} // end of bean + + + + + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/home.jsp b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/home.jsp new file mode 100644 index 0000000..88bb2d0 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/home.jsp @@ -0,0 +1,7 @@ + + + +
+Welcome +
+ diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/s.bat b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/s.bat new file mode 100644 index 0000000..c3d2acd --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/classes/obs/s.bat @@ -0,0 +1,3 @@ +path c:\jdk1.4\bin;c:\windows\system32 +set classpath=.;c:\jdk1.4\lib\tools.jar;c:\tomcat\common\lib\servlet.jar;c:\tomcat\common\lib\xerces.jar;d:\tomcat\common\lib\activation.jar;c:\tomcat\common\lib\mail.jar;c:\tomcat\webapps\obs\web-inf\classes;c:\tomcat\webapps\obs\web-inf\lib\order_client.jar;c:\weblogic\weblogic700\server\lib\weblogic.jar + diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/lib/order_client.jar b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/lib/order_client.jar new file mode 100644 index 0000000..e3910cd Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/lib/order_client.jar differ diff --git a/Online Book Store Project in JAVA/Online Book Store/WEB-INF/web.xml b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/web.xml new file mode 100644 index 0000000..c7555ef --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/WEB-INF/web.xml @@ -0,0 +1,13 @@ + + + + + + + + login.html + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/addbook.jsp b/Online Book Store Project in JAVA/Online Book Store/addbook.jsp new file mode 100644 index 0000000..bccca63 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/addbook.jsp @@ -0,0 +1,21 @@ + + + +<% + // check whether user has logged in, otherwise send user to login page + out.println( user.isLogged()); + + if (!user.isLogged()) + response.sendRedirect("login.html"); + + // read data about item + + String isbn = request.getParameter("isbn"); + + cart.addItem(isbn); + + response.sendRedirect("home.jsp"); + +%> + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/browsebooks.jsp b/Online Book Store Project in JAVA/Online Book Store/browsebooks.jsp new file mode 100644 index 0000000..b2b04ee --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/browsebooks.jsp @@ -0,0 +1,42 @@ + + + + + +

Browse Available Books

+ +
+Select Category : + + + +Query Books   Home + +
+ +<% + String cat = request.getParameter("cat"); + if ( cat == null) + request.setAttribute("cond","1=1"); +else + if (!cat.equals("all") ) + request.setAttribute("cond", "cat='" + cat + "'"); + +%> + + + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/changeprofile.html b/Online Book Store Project in JAVA/Online Book Store/changeprofile.html new file mode 100644 index 0000000..78912ba --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/changeprofile.html @@ -0,0 +1,68 @@ + + + + + +

Change Profile

+
+
+ + + + + + + + + + + + + + + + + + + +
+User Name + +* +
+Password + +* +
+Confirm Password + +* +
+Email Address + +* +
Mailing Address + +* +
+Phone Number + + +
+

+ + + +

+Go Back +

+ + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/changeprofile.jsp b/Online Book Store Project in JAVA/Online Book Store/changeprofile.jsp new file mode 100644 index 0000000..d242d7a --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/changeprofile.jsp @@ -0,0 +1,94 @@ + + + + +<% + if (!user.isLogged()) + response.sendRedirect("login.html"); + +%> + + + + + + +

Change Profile

+
+

Personal Details

+ + + + + + + + + + +
+Email Address + +> +
Mailing Address + + +
+Phone Number + + +
+ +

Password

+ + + + + + + +
+New Password + + +
+Confirm Password + + +
+ +

+ + + + Home Page +

+ + +<% + + // do it if any invoked by itself + if ( request.getParameter("email") == null) + return; + + String res = user.updateProfile( request.getParameter("pwd") ); + + if ( res == null) + out.println("Profile Updated Successfully."); + else + out.println("Error : " + res); + + out.println("Click here to continue..."); + +%> + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/deleteorder.jsp b/Online Book Store Project in JAVA/Online Book Store/deleteorder.jsp new file mode 100644 index 0000000..3b29606 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/deleteorder.jsp @@ -0,0 +1,30 @@ + + + +<% + // check whether user has logged in, otherwise send user to login page + + if (!user.isLogged()) + response.sendRedirect("login.html"); + + // read data about item + + String ordid = request.getParameter("ordid"); + + boolean result = cart.cancelOrder( Integer.parseInt(ordid)); + if ( result ) + out.println("

Order Has Been Cancelled.

"); + else + out.println("

Order could not be cancelled.

"); + + + +%> + +

+Orders History +   +Home Page + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/gohome.jsp b/Online Book Store Project in JAVA/Online Book Store/gohome.jsp new file mode 100644 index 0000000..f3e9a9d --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/gohome.jsp @@ -0,0 +1,8 @@ + + +<% + if ( user.isLogged() ) + response.sendRedirect("home.jsp"); + else + response.sendRedirect("login.html"); +%> diff --git a/Online Book Store Project in JAVA/Online Book Store/home.jsp b/Online Book Store Project in JAVA/Online Book Store/home.jsp new file mode 100644 index 0000000..166eb8c --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/home.jsp @@ -0,0 +1,159 @@ + + + + + +<%@ page import="java.util.*"%> + + + +<% + String act = request.getParameter("act"); + + if ( act != null ) + { + if( act.equals("Finalize Order")) + { + String orderid; + + orderid = cart.finalizeOrder( user.getUserid()); + if ( orderid == null) + { + out.println("Sorry! Order Cannot be finalized."); + return; + } + else + { + out.println("Order Has Been Finalized. Order id : " + orderid ); + out.println("Continue..."); + cart.clearAll(); + return; + } + + + } + + if ( act.equals("remove")) + { + cart.removeItem( request.getParameter("isbn")); + } + else + if ( act.equals("Update Cart")) + { + + String isbn[] = (String []) request.getParameterValues("isbn"); + String qty[] = (String []) request.getParameterValues("qty"); + + for (int i = 0 ;i < isbn.length ;i ++) + cart.updateQty(isbn[i], Integer.parseInt( qty[i])); + + } + else + if ( act.equals("Clear Cart")) + cart.clearAll(); + } // end of outer if + + +%> + + + + + + + + + + + + + + + + + + + +
+Welcome +
+

Shopping Cart

+ + + + + + +
+ +
+ + + + +<% + obs.Item item; + + ArrayList items = cart.getItems(); + Iterator itr = items.iterator(); + int total = 0; + + while ( itr.hasNext()) + { + item = (obs.Item) itr.next(); + total += item.getQty() * item.getPrice(); +%> + + + + +<% + } +%> + + + + +
Book Title +Price +Quantity +Amount +  +
+ name=isbn> +<%= item.getTitle()%> +<%= item.getPrice()%> +> +<%=item.getQty() * item.getPrice()%> +>Remove +
+Total Amount : <%=total%> +
+ +
+ + +

+ +

+ + +

+ + + +
+[Change User Details]    +[Browse Books]    +[Query Books]    +[Orders History]    +[ Logout ] +
+ + + diff --git a/Online Book Store Project in JAVA/Online Book Store/image.gif b/Online Book Store Project in JAVA/Online Book Store/image.gif new file mode 100644 index 0000000..87dd41c Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/image.gif differ diff --git a/Online Book Store Project in JAVA/Online Book Store/listbooks.jsp b/Online Book Store Project in JAVA/Online Book Store/listbooks.jsp new file mode 100644 index 0000000..f821e64 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/listbooks.jsp @@ -0,0 +1,58 @@ + +<%@ page import="java.sql.*"%> + +

List Of Books

+ + + + +<% + + String cond = (String) request.getAttribute("cond"); + if ( cond == null) + cond = "1 = 1"; + + Connection con = user.getConnection(); + Statement st= con.createStatement(); + + ResultSet rs = st.executeQuery("select rownum,isbn,title,author,price,cat,pub from books where " + cond); + + while (rs.next()) + { + +%> + + + +<% + } + rs.close(); + st.close(); + con.close(); +%> + +
  +Serial No +ISBN +Title +Price +Author +Cateogry +Publisher +
+>Add TO Cart +<%=rs.getInt(1)%> +<%=rs.getString(2)%> +<%=rs.getString(3)%> +<%=rs.getString(4)%> +<%=rs.getInt(5)%> +<%=rs.getString(6)%> +<%=rs.getString(7)%> +
+ + + + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/login.html b/Online Book Store Project in JAVA/Online Book Store/login.html new file mode 100644 index 0000000..e249f8e --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/login.html @@ -0,0 +1,54 @@ + + + +
Online Book Store
+ + + + +
+
+

Login

+Username +
+ +
+Password +
+ +

+ +

+I Am New User +

+
+

Introduction

+This site allows you to purchase books online. All that you have to do is add selected books to shopping cart and finalize the order. Books selected by you will be delivered to your door steps. You can pay only after books are delivered. + +

+The following are the required steps : +

    +
  • Login if already registered. Otherwise register as a user. Registration is free. +
  • Browser books and add books to shopping cart. Browsing is allowed to everyone, but only registed users can place order. +
  • You can modify shopping cart at your will +
  • Finalize the order. +
  • Pay for books when they are deliverd to your door steps. +
+ +

+

+Browse Available Books +

+ +

+
+ + + diff --git a/Online Book Store Project in JAVA/Online Book Store/login.jsp b/Online Book Store Project in JAVA/Online Book Store/login.jsp new file mode 100644 index 0000000..5416ff9 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/login.jsp @@ -0,0 +1,25 @@ + + + +
+ + + + + +<% + user.login(); + if (! user.isLogged()) +%> +

Invalid Login. Click here to try again!

+<% + else + response.sendRedirect("home.jsp"); +%> + +
+ + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/logout.jsp b/Online Book Store Project in JAVA/Online Book Store/logout.jsp new file mode 100644 index 0000000..3841647 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/logout.jsp @@ -0,0 +1,4 @@ +<% + session.invalidate(); + response.sendRedirect("login.html"); +%> diff --git a/Online Book Store Project in JAVA/Online Book Store/order/Client.java b/Online Book Store Project in JAVA/Online Book Store/order/Client.java new file mode 100644 index 0000000..7102a60 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/Client.java @@ -0,0 +1,34 @@ +package st.hello; + +import java.rmi.RemoteException; +import java.util.Properties; +import javax.naming.*; +import javax.ejb.*; +import javax.rmi.PortableRemoteObject; + +public class Client { + private static final String JNDI_NAME = "st.hello"; + + public static void main(String[] args) throws Exception + { + String url = "t3://localhost:7001"; + + Properties h = new Properties(); + h.put(Context.INITIAL_CONTEXT_FACTORY, + "weblogic.jndi.WLInitialContextFactory"); + h.put(Context.PROVIDER_URL, url); + Context ctx = new InitialContext(h); + + // Lookup the beans home using JNDI + + Object home = ctx.lookup(JNDI_NAME); + HelloHome hellohome = (HelloHome) PortableRemoteObject.narrow(home,HelloHome.class); + + Hello hello = hellohome.create(); + + System.out.println(hello.sayHello("Srikanth")); + + } + + +} diff --git a/Online Book Store Project in JAVA/Online Book Store/order/Item.java b/Online Book Store Project in JAVA/Online Book Store/order/Item.java new file mode 100644 index 0000000..7f6210b --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/Item.java @@ -0,0 +1,45 @@ +// Item class +package obs; + +public class Item + implements java.io.Serializable +{ + + private String isbn,title; + private int price; + private int qty; + + public Item(String isbn,String title, int price) + { + this.isbn = isbn; + this.title = title; + this.price = price; + this.qty = 1; + } + public String getIsbn() + { + return isbn; + } + + public String getTitle() + { + return title; + } + + public int getQty() + { + return qty; + } + + public void setQty(int qty) + { this.qty = qty; } + + public void addQty(int qty) + { this.qty += qty; } + + public int getPrice() + { + return price; + } +} // end of class + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/order/Order.java b/Online Book Store Project in JAVA/Online Book Store/order/Order.java new file mode 100644 index 0000000..3398c6f --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/Order.java @@ -0,0 +1,13 @@ +package obs.order; + +import java.rmi.RemoteException; +import javax.ejb.EJBObject; +import java.util.*; + +public interface Order extends EJBObject +{ + + public String addOrder(int userid, ArrayList items) + throws RemoteException; + public boolean cancelOrder(int ordid) throws RemoteException; +} diff --git a/Online Book Store Project in JAVA/Online Book Store/order/OrderBean.java b/Online Book Store Project in JAVA/Online Book Store/order/OrderBean.java new file mode 100644 index 0000000..6b223e0 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/OrderBean.java @@ -0,0 +1,153 @@ +package obs.order; + +import javax.ejb.*; +import javax.naming.*; +import javax.sql.*; +import java.sql.*; +import java.util.*; +import obs.*; + + + +public class OrderBean implements SessionBean { + + public void ejbActivate() {} + public void ejbRemove() {} // end of remove + + public void ejbPassivate() {} + public void setSessionContext(SessionContext ctx) {} + + public void ejbCreate () throws CreateException {} + + + public String addOrder(int userid, ArrayList items) + { + Connection con=null; + String ordid; + PreparedStatement ps=null; + + try + { + + Context ctx = new InitialContext(); + DataSource ds = (DataSource) ctx.lookup("oracle"); + con =ds.getConnection(); + + // get highest order id + 1 for this order + ps= con.prepareStatement("select ordid.nextval from dual"); + ResultSet rs= ps.executeQuery(); + rs.next(); + + ordid = rs.getString(1); + + rs.close(); + + // get total amount + + int totamt =0; + Item item; + + Iterator itr = items.iterator(); + while ( itr.hasNext()) + { + item = (Item) itr.next(); + totamt += item.getPrice() * item.getQty(); + } + + + ps = con.prepareStatement("insert into orders values(?,?,sysdate,?,'n')"); + ps.setString(1,ordid); + ps.setInt(2,userid); + ps.setInt(3,totamt); + + ps.executeUpdate(); + ps.close(); + + // insert into orderitems + + ps = con.prepareStatement("insert into orderitem values(?,?,?,?)"); + + itr = items.iterator(); + while ( itr.hasNext()) + { + item = (Item) itr.next(); + ps.setString(1,ordid); + ps.setString(2, item.getIsbn()); + ps.setInt(3,item.getPrice()); + ps.setInt(4,item.getQty()); + + ps.executeUpdate(); + } + + + return ordid; + + } + catch(Exception ex) + { + ex.printStackTrace(); + } + finally + { + try + { if (ps != null ) ps.close(); + if (con != null) con.close(); + } + catch(Exception ex) {} + } + return null; + + } // end of addOrder + + + + public boolean cancelOrder(int ordid) + { + Connection con=null; + PreparedStatement ps=null; + + try + { + + Context ctx = new InitialContext(); + DataSource ds = (DataSource) ctx.lookup("oracle"); + con =ds.getConnection(); + + // delete from ORDERITEM table + + ps = con.prepareStatement("delete from orderitem where ordid = ?"); + ps.setInt(1,ordid); + + ps.executeUpdate(); + ps.close(); + + // delete from ORDERS table + + ps = con.prepareStatement("delete from orders where ordid = ?"); + ps.setInt(1,ordid); + + int cnt = ps.executeUpdate(); + ps.close(); + + if (cnt == 1) return true; + else return false; + + + } + catch(Exception ex) + { + ex.printStackTrace(); + } + finally + { + try + { if (ps != null ) ps.close(); + if (con != null) con.close(); + } + catch(Exception ex) {} + } + return false; + + } // end of cancelOrder + +} // end of OrderBean diff --git a/Online Book Store Project in JAVA/Online Book Store/order/OrderHome.java b/Online Book Store Project in JAVA/Online Book Store/order/OrderHome.java new file mode 100644 index 0000000..e5f5a69 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/OrderHome.java @@ -0,0 +1,9 @@ +package obs.order; + +import java.rmi.RemoteException; +import javax.ejb.CreateException; +import javax.ejb.EJBHome; + +public interface OrderHome extends EJBHome { + Order create() throws CreateException, RemoteException; +} diff --git a/Online Book Store Project in JAVA/Online Book Store/order/Se.bat b/Online Book Store Project in JAVA/Online Book Store/order/Se.bat new file mode 100644 index 0000000..e7d0227 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/Se.bat @@ -0,0 +1,4 @@ +set classpath=.;c:\jdk1.4\lib\tools.jar;c:\weblogic\weblogic700\server\lib\weblogic.jar;d:\weblogic7\weblogic700 + +path=c:\weblogic\weblogic700\server\bin;c:\jdk1.4\bin;c:\windows\system32 + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/application.xml b/Online Book Store Project in JAVA/Online Book Store/order/application.xml new file mode 100644 index 0000000..e6d89dc --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/application.xml @@ -0,0 +1,14 @@ + + + + + + Order Bean + Online Book Store - Order Bean + + + order.jar + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build.xml b/Online Book Store Project in JAVA/Online Book Store/order/build.xml new file mode 100644 index 0000000..8e1cb1e --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/build.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/ejb-jar.xml b/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/ejb-jar.xml new file mode 100644 index 0000000..361b73d --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/ejb-jar.xml @@ -0,0 +1,19 @@ + + + + + + + + Order + obs.order.OrderHome + obs.order.Order + obs.order.OrderBean + Stateless + Container + + + order_client.jar + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/weblogic-ejb-jar.xml b/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/weblogic-ejb-jar.xml new file mode 100644 index 0000000..0b7242f --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/build/META-INF/weblogic-ejb-jar.xml @@ -0,0 +1,13 @@ + + + + + + + Order + obs.order + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/obs/Item.class b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/Item.class new file mode 100644 index 0000000..72b9006 Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/Item.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/Order.class b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/Order.class new file mode 100644 index 0000000..63031e6 Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/Order.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderBean.class b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderBean.class new file mode 100644 index 0000000..1bfbed6 Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderBean.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderHome.class b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderHome.class new file mode 100644 index 0000000..b40cd0b Binary files /dev/null and b/Online Book Store Project in JAVA/Online Book Store/order/build/obs/order/OrderHome.class differ diff --git a/Online Book Store Project in JAVA/Online Book Store/order/ejb-jar.xml b/Online Book Store Project in JAVA/Online Book Store/order/ejb-jar.xml new file mode 100644 index 0000000..361b73d --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/ejb-jar.xml @@ -0,0 +1,19 @@ + + + + + + + + Order + obs.order.OrderHome + obs.order.Order + obs.order.OrderBean + Stateless + Container + + + order_client.jar + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/examples.properties b/Online Book Store Project in JAVA/Online Book Store/order/examples.properties new file mode 100644 index 0000000..8acef14 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/examples.properties @@ -0,0 +1,24 @@ +#choose classic, modern, jikes, or jvc +JAVAC=modern +BEA_HOME=C:/weblogic +WL_HOME=C:/weblogic/weblogic700 +SAMPLES_HOME=C:/weblogic/weblogic700/samples +CLIENT_CLASSES=C:/weblogic/weblogic700/samples/server/stage/examples/clientclasses +SERVER_CLASSES=C:/weblogic/weblogic700/samples/server/stage/examples/serverclasses +EX_WEBAPP_CLASSES=C:/weblogic/weblogic700/samples/server/stage/examples/examplesWebApp/WEB-INF/classes +EX_WEBAPP=C:/weblogic/weblogic700/samples/server/stage/examples/examplesWebApp +APPLICATIONS=C:/weblogic/weblogic700/samples/server/config/examples/applications +CLASSPATH=${java.class.path} +XMLRegistry=C:/weblogic/weblogic700/samples/server/config/examples/xml/registries/examplesXMLRegistry +PORT=7001 +WINDOWS="Windows XP,Windows 2000,Windows NT,Windows 98,Windows 95" +UNIX="HP-UX,Solaris,SunOS,AIX,Linux" + +# Database properties +# These user defined properties are available to automate +# table setup for those examples that use an Oracle database. +DBSERVER= +DBPORT= +SID= +USER= +PASSWORD= diff --git a/Online Book Store Project in JAVA/Online Book Store/order/setclientenv.bat b/Online Book Store Project in JAVA/Online Book Store/order/setclientenv.bat new file mode 100644 index 0000000..3f583cc --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/setclientenv.bat @@ -0,0 +1,4 @@ +set classpath=.;d:\jdk1.4\lib\tools.jar;d:\weblogic7\weblogic700\server\lib\weblogic.jar;d:\weblogic7\weblogic700\samples\server\stage\examples\clientclasses;d:\weblogic7\weblogic700\samples\server\stage\examples\clientclasses\hello_client.jar + +path=d:\weblogic7\weblogic700\server\bin;d:\jdk1.4\bin;c:\windows\system32 + diff --git a/Online Book Store Project in JAVA/Online Book Store/order/weblogic-ejb-jar.xml b/Online Book Store Project in JAVA/Online Book Store/order/weblogic-ejb-jar.xml new file mode 100644 index 0000000..0b7242f --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/order/weblogic-ejb-jar.xml @@ -0,0 +1,13 @@ + + + + + + + Order + obs.order + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/orderitems.jsp b/Online Book Store Project in JAVA/Online Book Store/orderitems.jsp new file mode 100644 index 0000000..c4fa632 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/orderitems.jsp @@ -0,0 +1,91 @@ + +<%@page import="java.sql.*"%> + + + + + +

Order Items

+ + + +<% + String ordid = request.getParameter("ordid"); + String status = request.getParameter("status"); + + String cmd = "select oi.isbn,title, oi.price,qty, oi.price * qty amount from orderitem oi, books b where b.isbn = oi.isbn and ordid = " + ordid; + + + Connection con = user.getConnection(); + Statement st = con.createStatement(); + + ResultSet rs = st.executeQuery(cmd); + +%> + +

+ + + + + + +<% + while ( rs.next()) + { +%> + + + + +<% + } + + rs.close(); + st.close(); + con.close(); + +%> + + +
ISBN + Title + Price + Quantity + Amount +
<%=rs.getInt(1)%> + <%= rs.getString(2)%> + <%= rs.getInt(3)%> + <%= rs.getString(4)%> + <%= rs.getString(5)%> +
+ +

+<% + if ( status.equals("n")) + { +%> + +Cancel This Order +  +  +<% + + + } +%> + + + +Back + + + + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/ordershistory.jsp b/Online Book Store Project in JAVA/Online Book Store/ordershistory.jsp new file mode 100644 index 0000000..50db2e2 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/ordershistory.jsp @@ -0,0 +1,107 @@ + +<%@page import="java.sql.*"%> + + + + + +

Orders History

+ + + + + + + +<% + String type = request.getParameter("type"); + String cmd = "select ordid, orddate, totamt,decode(status,'n','New','p','Processed','d','Dispatched','Completed') textstatus,status from orders where userid = " + user.getUserid(); + + if ( type != null) + { + + if ( type.equals("n")) + cmd += " and status = 'n'"; + else + if ( type.equals("p")) + cmd += " and status = 'p'"; + else + if ( type.equals("d")) + cmd += " and status = 'd'"; + else + if ( type.equals("c")) + cmd += " and status = 'c'"; + + } + + + Connection con = user.getConnection(); + Statement st = con.createStatement(); + + ResultSet rs = st.executeQuery(cmd); + +%> + +

+ + + + + + +<% + while ( rs.next()) + { +%> + + + + +<% + } + + rs.close(); + st.close(); + con.close(); + +%> + + +
Order Id + Order Date + Total Amount + Status +
<%=rs.getInt(1)%> + <%= rs.getString(2)%> + <%= rs.getInt(3)%> + <%= rs.getString(4)%> +
+ + + + + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/querybooks.jsp b/Online Book Store Project in JAVA/Online Book Store/querybooks.jsp new file mode 100644 index 0000000..d464e66 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/querybooks.jsp @@ -0,0 +1,87 @@ + + + + + + +

Query Books

+
+ + + + + + +
+Category + + +Title Contains + +
+Author Name Contains + + +Price From + +To + + +
+

+ +Home Page + +

+ +<% + String cat = request.getParameter("cat"); + if ( cat == null) + return; + + String cond = "1=1"; + + if (!cat.equals("all") ) + cond = cond + " and cat = '" + cat + "'"; + + String title = request.getParameter("title"); + + if ( !title.equals("")) + cond = cond + " and title like '%" + title + "%'"; + + + String author = request.getParameter("author"); + + if ( !author.equals("")) + cond = cond + " and author like '%" + author + "%'"; + + + String fromprice = request.getParameter("fromprice"); + + if ( !fromprice.equals("")) + cond = cond + " and price >= " + fromprice; + + String toprice = request.getParameter("toprice"); + + if ( !toprice.equals("")) + cond = cond + " and price <= " + toprice; + + request.setAttribute("cond", cond); + +%> + + + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/register.html b/Online Book Store Project in JAVA/Online Book Store/register.html new file mode 100644 index 0000000..709895c --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/register.html @@ -0,0 +1,68 @@ + + + + + +

New User Registration

+
+
+ + + + + + + + + + + + + + + + + + + +
+User Name + +* +
+Password + +* +
+Confirm Password + +* +
+Email Address + +* +
Mailing Address + +* +
+Phone Number + + +
+

+ + + +

+Go Back +

+ + + + \ No newline at end of file diff --git a/Online Book Store Project in JAVA/Online Book Store/register.jsp b/Online Book Store Project in JAVA/Online Book Store/register.jsp new file mode 100644 index 0000000..f0e0002 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/register.jsp @@ -0,0 +1,29 @@ + + + + +
+ + + + + +<% + String result = user.registerUser(); + + if ( result == null) + response.sendRedirect("home.jsp"); + else + out.println("

Sorry! Registration Failed With Error :

" + result + "

Try Again "); + +%> + +

+ + + + + diff --git a/Online Book Store Project in JAVA/Online Book Store/tables.txt b/Online Book Store Project in JAVA/Online Book Store/tables.txt new file mode 100644 index 0000000..2097b05 --- /dev/null +++ b/Online Book Store Project in JAVA/Online Book Store/tables.txt @@ -0,0 +1,79 @@ +create user obs identified by obs; +grant connect, resource to obs; + +connect obs/obs + +create table users +( userid number(5) primary key, + uname varchar2(20) not null unique, + pwd varchar2(10), + email varchar2(30) unique, + address varchar2(100), + phone varchar2(20) +); + + + +create table books +( isbn number(10) primary key, + title varchar2(30), + author varchar2(50), + pub varchar2(10), + cat varchar2(5), + price number(5) +); + + +create table orders +( ordid number(5) primary key, + userid number(5) references users(userid), + orddate date, + totamt number(6), + status char(1) +); + +create table orderitem +( ordid number(5) references orders(ordid), + isbn number(10) references books(isbn), + price number(5), + qty number(3), + primary key(ordid,isbn) +); + + +insert into users +values(1,'scott','tiger','scott@hotmail.com','12-2-23,Dwarakanagar,VSP-16', +'3434343'); + + +insert into users +values(2,'mike','tyson','tyson@hotmail.com','12-5-23,MVP Colony,VSP-43', +'2234343'); + +insert into books + values('1001','Prof. JSP','Wrox Team', +'Wrox','java',500); + +insert into books + values('5007','Prof. ASP.NET', +'Wrox Team', +'Wrox','.net',675); + +insert into books + values('2045','VB.NET Black Book', 'Steven Holtzner','DreamTech' +,'.net',450); + + +commit; + + + +create sequence ordid start with 1001; + + + + + + + + diff --git a/Online Book Store Project in JAVA/Project Synopsis/Project Abstract_Instructions.doc b/Online Book Store Project in JAVA/Project Synopsis/Project Abstract_Instructions.doc new file mode 100644 index 0000000..31a3e24 Binary files /dev/null and b/Online Book Store Project in JAVA/Project Synopsis/Project Abstract_Instructions.doc differ diff --git a/Online Book Store Project in JAVA/Readme.docx b/Online Book Store Project in JAVA/Readme.docx new file mode 100644 index 0000000..cf11c06 Binary files /dev/null and b/Online Book Store Project in JAVA/Readme.docx differ