www.ignousite.blogspot.com

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

m o c om . t o t.c p s po g o s l g b . o l e t i te.b s u si o n g i gnou i



Login.html

Page |2

m o .c

t o p

b . te

i s u

o n ig

s g lo

HTML5 Icon

bUNK iT Mobile SHOP



Prepared by : Sunil Poonia

www.ignousite.blogspot.com
Page
|3


Screen Shot : Login

m o .c

t o p

b . te

i s u

o n ig

s g lo

Category.html
HTML5 Icon

bUNK iT Mobile SHOP



Prepared by : Ignou study helper



t o p



b . te

i s u

Screenshot : Category

o n ig

s g lo

Prepared by : Ignou study helper

Page |4

ItemsList.html

Page |5

HTML5 Icon

bUNK iT Mobile SHOP



t o p

Storage Devices



Page |6



ScreenShot : Itemlist

m o .c

t o p

b . te

i s u

o n ig

s g lo

Feedback.html
HTML5 Icon

bUNK iT Mobile SHOP



www.ignousite.blogspot.com

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

Page |7



m o .c

t o p

b . te

i s u

o n ig

s g lo





ScreenShot : feedback

Prepared by : Sunil Poonia

www.ignousite.blogspot.com

Page |8

m o .c

t o p

AbstractDao:-

import import import import import import

b . te

i s u

package com.bunkit.bca5.dao;

o n ig

s g lo

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 : Sunil Poonia

www.ignousite.blogspot.com Provided By : ignou study helper { 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."); }

Page |9

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);

m o .c

returncon; }

t o p

}

Db.properties:-

s g lo

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

LoginAction.java:-

b . te

o n ig

i s u

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 : Sunil Poonia

www.ignousite.blogspot.com { ActionContext.setAttribute("user", user,ActionContext.SessionScope); return "validUser"; } else return "invalidUser"; }

Page | 10

}

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; } }

t o p

s g lo

b . te

i s u

o n ig

m o .c

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 Study Helper

www.ignousite.blogspot.com } 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.

b . te

i s u

o n ig

t o p

s g lo

stmt.setString(2,user.getMailId()); stmt.setString(3,user.getPassword()); //execute the query stmt.executeUpdate(); //close the connection con.close(); }

m o .c

//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 Study Helper

www.ignousite.blogspot.com Provided By : Sunil Poonia 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(); }

Page | 12

//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));

m o .c

t o p

s g lo

b . te

i s u

} //close the connection con.close(); //return the user object return user; }

o n ig

//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 Study Helper

www.ignousite.blogspot.com Provided By : Sunil Poonia

//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))); }

m o .c

t o p

//close the connection con.close(); //return the user object return user; } }

b . te

i s u

o n ig

s g lo

www.ignousite.blogspot.com IGNOU Study Helper

Prepared by : IGNOU Study Helper

Page | 13

m o c om . t o t.c p s po g o s l g b . o l e t i te.b s u si o n g i gnou i

BCSL-057.pdf

padding: 7px 25px;. border-radius: 5px;. } .footer {. text-align: center;. background: #333;. color: #fff;. padding: 15px 0;. } . Login.html. html>.

688KB Sizes 8 Downloads 151 Views

Recommend Documents

No documents