0% found this document useful (0 votes)
285 views

Aim: To Write A Program in XML For Creation of DTD Which Specifies Set of Rules. Script: Note - XML

The document discusses several programs related to web development and Java programming. Program 7 creates an XML file with DTD and displays it with CSS. Program 8 illustrates methods of the InetAddress class in Java. Program 9 creates a basic JDBC program to connect to a database. Program 10 explains how to install and configure Tomcat and Apache web servers to deploy static web pages for a book website.

Uploaded by

vohib80009
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)
285 views

Aim: To Write A Program in XML For Creation of DTD Which Specifies Set of Rules. Script: Note - XML

The document discusses several programs related to web development and Java programming. Program 7 creates an XML file with DTD and displays it with CSS. Program 8 illustrates methods of the InetAddress class in Java. Program 9 creates a basic JDBC program to connect to a database. Program 10 explains how to install and configure Tomcat and Apache web servers to deploy static web pages for a book website.

Uploaded by

vohib80009
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/ 8

Program-7

Aim: To write a program in XML for creation of DTD which specifies set of rules.
Create a style sheet in CSS & display the document in internet explorer.
Script:
note.xml
<?xml version = "1.0" encoding = "UTF-8" standalone = "yes" ?>
<?xml-stylesheet type="text/css" href="nt.css"?>
<!DOCTYPE address [
<!ELEMENT address (name,company,phone)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
]>
<address>
<name>Harshvardhan Bahukhandi</name>
<company>Galgotia College</company>
<phone>9406245966</phone>
</
address
>
nt.css
addres
s{
color: white;
background-color : rgb(130, 34, 255);
width: 100%;
}
name {
color: rgb(0,
0, 0); font-
size : 40px;
background-color : powderblue;
}
company
{ display :
block;
}
phone {
font-size :
25px; font-
weight :
bold;
}

OUTPUT
Program-8
Aim: To write a program in java to illustrate Methods of InetAddress Class.
Source Code:

import java.io.IOException;
import java.net.InetAddress;
import java.util.Arrays;

public class sample {


public static void main(String[] args)
throws IOException {
// Input sample URL
String url = "www.google.com";
byte addr[] = { 127, 0, 0, 1 };
// getByName() method
InetAddress ip1 = InetAddress.getByName(url);
System.out.println("getByName() : " + ip1);
// getByAddress() method
InetAddress ip2 = InetAddress.getByAddress(addr);
System.out.println("getByAddress() : " + ip2);
// getLocalHost() method
InetAddress ip3 = InetAddress.getLocalHost();
System.out.println("getLocalHost() : " + ip3);
// getLoopbackAddress() method
InetAddress ip4 = InetAddress.getLoopbackAddress();
System.out.println("getLoopbackAddress() : " + ip4);
// getAllByName() method
// Returns all ip addresses associated with 'google.com'
InetAddress addrs[] = InetAddress.getAllByName("www.google.com");
System.out.println("Google ip addresses : " + Arrays.toString(addrs));
// isReachable() method
boolean isreach = ip1.isReachable(50);
System.out.println("ip1 isReachable() : " + isreach);
// getHostname() method
String hostname = ip1.getHostName();
System.out.println("ip1 hostname :" + hostname);
// getCanonicalHostname() method
System.out.println("ip1 CanonicalHostname : " + ip1.getCanonicalHostName());
// toString() method
System.out.println("ip1 toString() : " + ip1.toString());
}

}
Program-9
Aim: Write a program to illustrate JDBC connectivity program for maintaining database for
sending queries.
Code:
import java.sql.* ;
class Db {
public static void main(String[] args) {
try{

String db_url = "jdbc:mysql://localhost:3306/registration";


Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection( db_url , "nav" , "mithu123");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from Student");
while(rs.next()) {
int id = rs.getInt(1);
String name = rs.getString(2);
String email = rs.getString(3);
String phone = rs.getString(4);
System.out.println("Id :- " + id + " Name :- " + name + " Email :- " + email + "
Phone :- " + phone);
}

}catch(Exception e){
System.out.println(e);
}
}
}
Output:
Program -10

Aim : Install TOMCAT web server and APACHE. Access the developed static web pages for
books web site, using these servers by putting the web pages developed.
Theory:
Set the JAVA_HOME Variable
You must set the JAVA_HOME environment variable to tell Tomcat where to find Java. Failing
to properly set this variable prevents Tomcat from handling JSP pages. This variable should list
the base JDK installation directory, not the bin subdirectory.
install the tomcat server -
now config servlets with tomcat manually -
1st install the tomcat server -> inside c:\drive -> c:\tomcat with 8090 port no.
now create own folder inside c:\tomcat/webapps\ with
- create config files + folder inside Ananya folder -
Ananya
- WEB-INF
-classes - contain the all servlets + bean classes - with package or without package
- web.xml - for servlets & URL mapping
- tld files - for custom tags
- lib contain all jar files
-images - contain all project images
-css - contain all project css files
- js - contain all js files
web pages
or
copy the WEB-INF folder from example folder & paste inside Ananya folder & edit it.
- Web.xml coding
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<display-name>Ananya Servlet and JSP Examples</display-name>
<!-- Servlet mapping -->
<servlet>
<servlet-name>al</servlet-name>
<servlet-class>Hello</servlet-class>
</servlet>
<!-- URL mapping -->
<servlet-mapping>
<servlet-name>al</servlet-name>
<url-pattern>/Wel</url-pattern>
</servlet-mapping>
</web-app>
- now create own servlet file & save inside WEB – INF folder
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Hello extends HttpServlet {
@Override
public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException , IOException {
String u = (String)req.getAttribute("id");
PrintWriter out = res.getWriter(); // out hold the response writer for
response write
out.println("<body bgcolor = lightyellow><pre><h1>Hello "+u+", Welcome to Servlets</h1>");
}
}
save Inside - WEB-INF\Hello.java
now open the dos prompt -> dos -
c:\tomcat\webapps\Ananya\WEB-INF>set classpath =c:\tomcat\lib\servlet-api.jar; - without any
space
c:\tomcat\webapps\Ananya\WEB-INF>javac -d classes Hello.java now open the web.xml file &
entries for Servlet mapping & URL Mapping.
now open the browser http:\\localhost:8095\Ananya\Wel

You might also like