www.onlinecode.in Provided By : bUNK iT

Page |1

1. Create a website for an e-commerce company selling only the electronic goods. The website uses divisions and an external CSS file. Every page of the website is divided into four divisions namely – HEADING, FOOTER, MENU and CONTENT. (40 Marks) Solution: Mystyle.css

Page |2

Login.html
HTML5 Icon

bUNK iT Mobile SHOP



Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : bUNK iT
Page
|3


Screen Shot : Login

Category.html
HTML5 Icon

bUNK iT Mobile SHOP



Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : bUNK iT








Screenshot : Category

Prepared by : IGNOU ROCK

Page |4

www.onlinecode.in Provided By : bUNK iT ItemsList.html
HTML5 Icon

bUNK iT Mobile SHOP

Storage Devices



Page |6



ScreenShot : Itemlist

Feedback.html
HTML5 Icon

bUNK iT Mobile SHOP



Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : bUNK iT

href="login.html">Login
href="category.html">Category href="itemslist.html">Items list href="feedback.html">Feedback



ScreenShot : feedback

Prepared by : IGNOU ROCK

Page |7

www.onlinecode.in Provided By : bUNK iT

Page |8

AbstractDao:package com.bunkit.bca5.dao; import import import import import import

java.io.FileOutputStream; java.io.InputStream; java.net.URL; java.sql.*; java.util.Properties; org.apache.log4j.Logger;

publicabstractclass AbstractDao { static Properties prop; static Logger logger=Logger.getRootLogger(); static { prop=new Properties(); try { InputStream in= AbstractDao.class.getResourceAsStream("/db.properties"); prop.load(in); logger.info("properties loaded."); }catch(Exception ex) { logger.error(ex); } } publicvoid saveProperties() throws Exception

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : bUNK iT { String url=AbstractDao.class.getResource("/db.properties").getPath(); logger.info("db properties are saved at: "+url); FileOutputStream out=new FileOutputStream(url); prop.store(out, "db properties configured by the user."); } public Connection getConnection() throws Exception { Connection con=null; //To create a database connection for MySql Class.forName(prop.getProperty("driverClass")); String url=prop.getProperty("url"); String user=prop.getProperty("user"); String pass=prop.getProperty("password"); if(user==null) con=DriverManager.getConnection(url); else con= DriverManager.getConnection(url,user,pass); returncon; }

}

Db.properties:driverClass=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/?user=root&password user=bunkit password=jaimatadi

LoginAction.java:package com.bunkit.bca4.dao; import org.apache.log4j.Logger; import com.swinfosoft.mvc.web.*; public class LoginAction implements Action { //method to process request public String processRequest() throws Exception { Logger logger=Logger.getRootLogger(); //read request data from ActionContext User user=new User(); user.setMailId( ActionContext.getParameter("userId")); user.setPassword( ActionContext.getParameter("password")); UserDao dao=new UserDao(); logger.info("ActionContext.getParameter(userId) "+ActionContext.getParameter("userId")); logger.info("ActionContext.getParameter(password) "+ActionContext.getParameter("password")); if(dao.findUser(user))

Prepared by : IGNOU ROCK

Page |9

www.onlinecode.in Provided By : bUNK iT { ActionContext.setAttribute("user", user,ActionContext.SessionScope); return "validUser"; } else return "invalidUser"; } }

PostMaster.java:package com.bunkit.bca4.dao; import java.util.*; publicclass PostMaster {

}

privateintid; private String title,content; publicint getId() { returnid; } publicvoid setId(intid) { this.id = id; } public String getTitle() { returntitle; } publicvoid setTitle(String title) { this.title = title; } public String getContent() { return content; } publicvoid setContent(String content) { this.content = content; }

User.java:package com.bunkit.bca4.dao; publicclass User { privateint id; private String mailId,password; publicint getId() { returnid; } publicvoid setId(intid) { this.id = id; } public String getMailId() { returnmailId; } publicvoid setMailId(String mailId) { this.mailId = mailId; } public String getPassword() { returnpassword;

Prepared by : IGNOU ROCK

Page | 10

www.onlinecode.in Provided By : bUNK iT } publicvoid setPassword(String password) { this.password = password; } }

UserDao.java:-

Page | 11

package com.bunkit.bca4.dao; import java.sql.*; import org.apache.log4j.Logger; public class UserDao extends AbstractDao { Logger logger=Logger.getRootLogger(); //Method to save the user public void save(User user) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "insert into UserMaster (mailid,password)" + " values(?,?,?)"); //set the value of parameters. stmt.setString(2,user.getMailId()); stmt.setString(3,user.getPassword()); //execute the query stmt.executeUpdate(); //close the connection con.close(); } //Method to update the user public void resetPassword(String p,String mid) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "update usermaster set password=? where mailId=?"); //set the value of parameters. stmt.setString(1,p); stmt.setString(2,mid); //execute the query stmt.executeUpdate(); //close the connection logger.info("sucessfully reset your password "); con.close(); } //Method to delete the user public void delete(int userId) throws Exception { //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query.

Prepared by : IGNOU ROCK

www.onlinecode.in Provided By : bUNK iT PreparedStatement stmt=con.prepareStatement( "delete from UserMaster where id=?"); //set the value of parameters. stmt.setInt(1, userId); //execute the query stmt.executeUpdate(); //close the connection con.close(); } //Method to load a user using id public User getById(int userId) throws Exception { User user=null; //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "select * from UserMaster where userId=?"); //set the value of parameters. stmt.setInt(1, userId); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { user=new User(); //store record data in object user.setId(rset.getInt(1)); user.setMailId(rset.getString(2)); user.setPassword(rset.getString(3)); } //close the connection con.close(); //return the user object return user; } //Method to find user using mailId and password public boolean findUser(User user) throws Exception { boolean flag=false; //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. PreparedStatement stmt=con.prepareStatement( "select * from usermaster where mailId=? and password=?"); //set the value of parameters. stmt.setString(1, user.getMailId()); stmt.setString(2, user.getPassword()); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { flag=true; //store record data in object user.setId(rset.getInt(1)); }

Prepared by : IGNOU ROCK

Page | 12

www.onlinecode.in Provided By : bUNK iT //close the connection con.close(); //return the user object return flag; } //find mail_id public User findMailId(String mailid) throws Exception { User user=new User(); //Connection is obtained. Connection con=getConnection();//super class method //Statement object is created to execute the query. logger.info(":::::user email id is "+mailid); PreparedStatement stmt=con.prepareStatement("select * from usermaster where mailId=?"); //set the value of parameters. stmt.setString(1, mailid); //execute the query ResultSet rset=stmt.executeQuery(); //read the result of select query if(rset.next())//if user is found. { //store record data in object user.setId(rset.getInt(1)); user.setMailId(rset.getString(2)); user.setPassword((rset.getString(3))); } //close the connection con.close(); //return the user object return user; } }

Prepared by : IGNOU ROCK

Page | 13

BCSL-057.pdf

divisions and an external CSS file. Every page of the website ... HTML5 Icon ... Displaying BCSL-057.pdf. Page 1 of ...

823KB Sizes 4 Downloads 150 Views

Recommend Documents

No documents