CS506 – Web Design and Development
In CS506 Web Design and Development we have you covered with Digitized Past Papers From Fall of Mid Term and Final Term.
NOTE: Tab/Click on Preparation Tab to take the MCQ’s Tests.
CS506_Finalbyshanzy View Download
CS506_FinalsolvedPapers2012 View Download
CS506_FINALTERMMCQS View Download
CS506_Finaltermsubjective View Download
MID TERM
cs506_mid_term View Download
CS506MIDTERMSOLVEDMCQSwithreferencesbyMOAAZ (2) View Download
CS506MIDTERMSOLVEDSUBJECTIVESwithrefrencesbyMOAAZ View Download
CS506 GDB SOLUTION POSTED DATE:30-01-2020
MAKE SOME CHANGESYes, use of worker thread along with main thread will reduce the response delay, thread allow utilization of multiprocessor architectures to a great scale and efficiency. Threads are we very little resources of an operating system in which they are working. That is thread do not need new address space, global data, program code or operating system resources. Main thread is responsible for everything that happens on screen after application starting. Responsive of your application UI that you do not block the UI thread. If you have operation to perform that are not instantaneous, you should make sure to do them in separate worker threads.
POSTED DATE:01-02-2019
person class
public class Person {
String CNIC;
String Name;
String DOB;
String Address;
public Person() {
super();
CNIC = “”;
Name = “”;
DOB = “”;
Address = “”;
}
public Person(String cNIC, String name, String dOB, String address) {
super();
CNIC = cNIC;
Name = name;
DOB = dOB;
Address = address;
}
public String getCNIC() {
return CNIC;
}
public void setCNIC(String cNIC) {
CNIC = cNIC;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getDOB() {
return DOB;
}
public void setDOB(String dOB) {
DOB = dOB;
}
public String getAddress() {
return Address;
}
public void setAddress(String address) {
Address = address;
}
};
//////////////////////////////////////////////////////////
Studen class
//////////////////////////////////////////////////////////
public class Student extends Person {
String ID;
String Program;
String Email;
public Student() {
super();
ID = “”;
Program = “”;
Email = “”;
}
public Student(String cNIC, String name, String dOB, String address, String iD, String program, String email) {
super(cNIC, name, dOB, address);
ID = iD;
Program = program;
Email = email;
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getProgram() {
return Program;
}
public void setProgram(String program) {
Program = program;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
Driver Class
/////////////////////////////////////////////////////////////////////////////////////////
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.*;
import java.sql.*;
public class Driver implements ActionListener {
JFrame frame;
private JLabel CNICLabel;
private JLabel idLabel;
private JLabel addressLabel;
private JLabel nameLabel;
private JLabel progLabel;
private JLabel DOBLabel;
private JLabel EmailLabel;
private JTextField CNICTxt;
private JTextField idTxt;
private JTextField addressTxt;
private JTextField nameTxt;
private JTextField progTxt;
private JTextField DOBTxt;
private JTextField EmailTxt;
private JPanel row1Panel;
private JPanel row2Panel;
private JPanel row3Panel;
private JPanel row4Panel;
private JPanel row5Panel;
private JPanel row6Panel;
private JButton saveRecord, retrieveRecord;
private Student student;
public void createFrame() {
frame = new JFrame(“BC160201501”);
Container c = frame.getContentPane();
c.setLayout(new GridLayout(6, 1, 10, 10));
CNICLabel = new JLabel(“Enter CNIC:”);
idLabel = new JLabel(“Enter ID:”);
nameLabel = new JLabel(“Enter Name:”);
DOBLabel = new JLabel(“Date of Birth:”);
progLabel = new JLabel(“Enter Program:”);
addressLabel = new JLabel(“Enter :Address”);
EmailLabel = new JLabel(“Enter Email:”);
CNICTxt = new JTextField(15);
idTxt = new JTextField(15);
nameTxt = new JTextField(15);
DOBTxt = new JTextField(15);
progTxt = new JTextField(15);
addressTxt = new JTextField(15);
EmailTxt = new JTextField(15);
row1Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
row1Panel.add(CNICLabel);
row1Panel.add(CNICTxt);
row1Panel.add(idLabel);
row1Panel.add(idTxt);
c.add(row1Panel);
row2Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
row2Panel.add(nameLabel);
row2Panel.add(nameTxt);
row2Panel.add(DOBLabel);
row2Panel.add(DOBTxt);
c.add(row2Panel);
row3Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
row3Panel.add(progLabel);
row3Panel.add(progTxt);
row3Panel.add(addressLabel);
row3Panel.add(addressTxt);
c.add(row3Panel);
row4Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
row4Panel.add(EmailLabel);
row4Panel.add(EmailTxt);
c.add(row4Panel);
saveRecord = new JButton(“Save Record”);
retrieveRecord = new JButton(“Retrieve Record”);
row5Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
row5Panel.add(saveRecord);
row5Panel.add(retrieveRecord);
c.add(row5Panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 400);
frame.setVisible(true);
saveRecord.addActionListener(this);
retrieveRecord.addActionListener(this);
}
public void addData(Student student) {
try{
Class.forName(“net.ucanaccess.jdbc.UcanaccessDriver”);
Connection con = DriverManager.getConnection(“jdbc:ucanaccess://E:/azhar/BC160201501.accdb”);
String sql = “SELECT * FROM Student”;
PreparedStatement pst = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = pst.executeQuery();
rs.moveToInsertRow();
rs.updateString(“CNIC”, student.getCNIC());
rs.updateString(“Name”, student.getName());
rs.updateString(“DOB”, student.getDOB());
rs.updateString(“Address”, student.getAddress());
rs.updateString(“id”, student.getID());
rs.updateString(“Program”, student.getProgram());
rs.updateString(“Email”, student.getEmail());
rs.insertRow();
}
catch (ClassNotFoundException e) {
System.out.println(“error” + e);
}
catch (SQLException ex) {
System.out.println(“error” + ex);
}
}
public void searchData(String id)
{
try {
Class.forName(“net.ucanaccess.jdbc.UcanaccessDriver”);
Connection con = DriverManager.getConnection(“jdbc:ucanaccess://E:/BC160201501/BC160201501.accdb”);
Statement st = con.createStatement();
String sql = “SELECT * FROM Student”;
ResultSet rs = st.executeQuery(sql);
int searchcount = 0;
while (rs.next()) {
String checkingCNIC = rs.getString(“CNIC”);
;
String checkingid = rs.getString(“id”);
if (id.equals(checkingCNIC) || id.equals(checkingid)) {
JOptionPane.showMessageDialog(null, “CNIC” + rs.getString(“CNIC”) + “/nid” + rs.getString(“id”) + “/nName” + rs.getString(“Name”)
+ “/nDOB” + rs.getString(“DOB”) + “/nProgram” + rs.getString(“Program”)+”/nAddress” + rs.getString(“Address”)
+ “/nEmail” + rs.getString(“Email”));
searchcount++;
}
if (searchcount == 0) {
JOptionPane.showMessageDialog(null, “No Record Found”);
}
}
} catch (ClassNotFoundException e) {
System.out.println(“error” + e);
} catch (SQLException ex) {
System.out.println(“error” + ex);
}
}
@Override
public void actionPerformed(ActionEvent event) {
if (event.getSource() == saveRecord)
{
String CNIC = CNICTxt.getText();
String id = idTxt.getText();
String Name = nameTxt.getText();
String DOB = DOBTxt.getText();
String Program = progTxt.getText();
String Address = addressTxt.getText();
String Email = EmailTxt.getText();
Student s1 = new Student(CNIC, id, Name, DOB,Program, Address, Email );
addData(s1);
}
if (event.getSource() == retrieveRecord)
{
String input = JOptionPane.showInputDialog(“Enter Your CNIC or Id”);
searchData(input);
}
}
public Driver() {
createFrame();
}
public static void main(String[] args) {
Driver d1 = new Driver();
}
}
CS506– Practice Quiz 1
CS506– Practice Quiz 2
CS506– Practice Quiz 3
CS506– Practice Quiz 4
CS506– Practice Quiz 5
Name any two logical layers of we application?
Answer:- (Page 321)
Presentation Layer
Business Layer
Data Layer
Write briefly 2 characteristic of EL?
Answer:- Click here for detail
Dynamically write data, such as user input into forms, to JavaBeans components
Invoke arbitrary static and public methods
Dynamically perform arithmetic operations
Why do we use session tracking in HTTP servlets?
Answer:- Click here for detail
In HttpServlet we can use Session Tracking to track the user state. Session is required if you are developing
shopping cart application or in any e-commerce application.
How JSP pages are informed about the error?
Answer:- (Page 393)
JSP pages are informed about the error page by setting errorPage attribute of page directive
8
Write Advantages of JASP over Servlet?
Answer:- (Page 330)
JSPs provide more convenient way to create HTML
JSPs can use standard front end tools (e.g., UltraDev)
JSPs divide and conquer the problem of presentation and business logic.
What is Significance of error Pages?
Answer:- (not confirm)
Error Pages enables you to customize error messages. You can even hide them from the user’s view entirely,
if you want.
Defining and Using Error Pages
• isErrorPage attribute of a page directive is used to declare a JSP as an error
page.
• JSP pages are informed about the error page by setting errorPage attribute of page directive
Write features that JSP provide?
Answer:- (Page 330)
Versus ASP or ColdFusion
JSPs offer better language for dynamic part i.e. java
JSPs are portable to multiple servers and operating systems
Versus PHP
JSPs offer better language for dynamic part
JSPs offer better tool support
Versus pure servlets
JSPs provide more convenient way to create HTML
JSPs can use standard front end tools (e.g., UltraDev)
JSPs divide and conquer the problem of presentation and business logic.
How can we encode URL which is sent to Client?
Answer:- (Page 317)
HttpServletResponse provides two methods to perform encoding
String encodeURL(String URL)
String encodeRedirectURL(String URL)
If Cookies are disabled, both methods encode (rewrite) the specific URL to include the session ID and returns
the new URL. However, if cookies are enabled, the URL is returned unchanged.