0% found this document useful (0 votes)
5 views13 pages

WT

The document outlines various programming tasks including creating an HTML form for student details, a JavaScript program to display browser information, a Java applet for a calculator, XML for DTD creation, and JDBC connectivity for database management. Each program includes objectives, code snippets, and explanations of their functionality. Additionally, it discusses the installation and use of Apache HTTP Server and Apache Tomcat for serving static and dynamic web content.

Uploaded by

akrativerma2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views13 pages

WT

The document outlines various programming tasks including creating an HTML form for student details, a JavaScript program to display browser information, a Java applet for a calculator, XML for DTD creation, and JDBC connectivity for database management. Each program includes objectives, code snippets, and explanations of their functionality. Additionally, it discusses the installation and use of Apache HTTP Server and Apache Tomcat for serving static and dynamic web content.

Uploaded by

akrativerma2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

1

Program 2

Objective: Write a HTML program to design an entry form of student details and send it to
store at database server like SQL, Oracle or MS Access

Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Details Form</title>
<style> body { font-family: Arial,
sans-serif; background-color:
#f4f4f4; margin: 0;
padding: 0;
}

.container { max-width:
500px; margin: 20px
auto; background-
color: #fff; padding:
20px; border-radius:
10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 { color: #333;
text-align: center;
margin-bottom: 20px;
}

label { display: block;


margin-bottom: 5px;
color: #666;
}

input[type="text"],

2
input[type="email"],
select {
width: 100%;
padding: 8px; margin-
bottom: 15px; border:
1px solid #ccc;
border- radius: 5px;
box-sizing: border-box;
}

input[type="submit"] {
background-color: #007bff;
color: #fff; padding: 10px
20px; border: none;
border-radius: 5px; cursor:
pointer;
}

input[type="submit"]:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Student Details Form</h1>
<form action="submit_student_details.php" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>

<label for="email">Email:</label>
<input type="email" id="email" name="email" required>

<label for="roll">Roll Number:</label>


<input type="text" id="roll" name="roll" required>

<label for="course">Course:</label>
<select id="course" name="course" required>
<option value="">Select Course</option>
<option value="Engineering">Engineering</option>
<option value="Medicine">Medicine</option>
<option value="Commerce">Commerce</option>
3
<option value="Arts">Arts</option>
</select>

<label for="semester">Semester:</label>
<input type="text" id="semester" name="semester" required>

<label for="dob">Date of Birth:</label>


<input type="text" id="dob" name="dob" placeholder="YYYY-MM-DD" required>

<input type="submit" value="Submit">


</form>
</div>
</body>
</html>

Output:

4
Program 3

Objective: Write programs using Java script for Web Page to display browsers information

Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Browser Information</title>
</head>
<body>
<h1>Browser Information</h1>
<p id="browserInfo"></p>
<script> var browserInfo = "Browser: "
+ navigator.userAgent;
document.getElementById("browserInfo").innerHTML = browserInfo; </script>
</body>
</html>

Ouput:

5
Program 4

Objective: Write a Java applet to display the Application Program screen i.e. calculator and
other.

Code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class CalculatorApplet extends Applet implements ActionListener
{ TextField display;
Button[] buttons;
String[] buttonLabels = {
"1", "2", "3", "+",
"4", "5", "6", "-",
"7", "8", "9", "*",
".", "0", "=", "/"
"(-)", "X", "C"
};

public void init() {


display = new
TextField(20);
display.setEditable(false);
add(display);

Panel buttonPanel = new Panel(new GridLayout(4,


4)); buttons = new Button[buttonLabels.length]; for
(int i = 0; i < buttonLabels.length; i++) {
buttons[i] = new Button(buttonLabels[i]);
buttons[i].addActionListener(this);
buttonPanel.add(buttons[i]);
}
add(buttonPanel);
}
public void actionPerformed(ActionEvent e) { String
command = e.getActionCommand();
if (command.equals("C")) { display.setText("");
} else if (command.equals("=")) {
try {
6
String expression = display.getText();

7
double result =
evaluateExpression(expression);
display.setText(String.valueOf(result));
} catch (Exception ex) { display.setText("Error");
}
} else {
display.setText(display.getText() + command);
}
}

private double evaluateExpression(String expression) throws Exception {


ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript"); return
(double) engine.eval(expression);
}
}

Output:

8
Program 5

Objective: Writing program in XML for creation of DTD, which specifies set of rules. Create a
style sheet in CSS/ XSL & display the document in internet explorer

Code:

XML code:

<?xml version="1.0"?>
<!DOCTYPE data SYSTEM "example.dtd">
<data>
<person>
<name>Sachin</name>
<age>48</age>
<email>[email protected]</email>
</person>
<person>
<name>Tom</name>
<age>62</age>
<email>[email protected]</email>
</person>
</data>

CSS code:

person { display:
block; margin-bottom:
20px; border: 1px
solid #ccc;
padding: 10px;
}
name { font-
weight: bold;
}

age, email { color:


#666;
}

HTML code :

9
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XML Display</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<xml src="example.xml" style="display:block; width:100%; height:100%;"></xml>
</body>
</html>

Output:

10
Program 6

Objective: Program to illustrate JDBC connectivity. Program for maintaining database by


sending queries. Design and implement a simple servlet book query with the help of JDBC &
SQL. Create MS Access Database, Create on ODBC link, Compile & execute JAVA JDVC Socket.
Code:

import java.sql.Connection; import java.sql.DriverManager;


import java.sql.ResultSet; import java.sql.SQLException;
import java.sql.Statement; public class JDBCExample {
private static final String JDBC_URL = "jdbc:odbc:BookDB";
private static final String USERNAME = ""; private static final
String PASSWORD = ""; public static void main(String[] args)
{
Connection conn =
null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
stmt = conn.createStatement(); String sql = "SELECT * FROM books"; rs =
stmt.executeQuery(sql);
while (rs.next()) {
String title = rs.getString("title");
String author =
rs.getString("author"); double price =
rs.getDouble("price");
System.out.println("Title: " + title + ", Author: " + author + ", Price: " + price);
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
} finally { try { if (rs != null)
rs.close(); if (stmt != null)
stmt.close(); if (conn != null)
conn.close();
} catch (SQLException e)
{ e.printStackTrace();
}
}}}

11
Program 7

Objective: Install TOMCAT web server and APACHE. Access the above developed static web
pages for books web site, using these servers by putting the web pages developed

Theory:

1. Apache HTTP Server:


- Widely used open-source web server software.
- Serves static web content efficiently.
- Easy to install and configure.
- Ideal for hosting HTML, CSS, JavaScript, and image files.

2. Apache Tomcat:
- Web server and servlet container for Java-based web applications.
- Executes Java servlets and renders JavaServer Pages (JSP).
- Used to handle dynamic content generation.
- Integrates with Apache HTTP Server to serve dynamic content while Apache serves static content.

3. Accessing Static Web Pages:


- Apache HTTP Server hosts static web pages directly from its document root.
- Apache Tomcat hosts dynamic content and Java-based web applications.
- Apache HTTP Server can be configured as a reverse proxy for Apache Tomcat.
- Requests for static content are served directly by Apache, while dynamic content requests
are forwarded to Tomcat.
- This setup allows for efficient handling of both static and dynamic content in a web
hosting environment.

12
13

You might also like