Professional Documents
Culture Documents
------------------------------------------------------------------------------------------------------------
AIM: Design the static web pages required for an online book store web site.
1) HOME PAGE
DESCRIPTION:
The static home page must contain three frames.
Top frame : Logo and the college name and links to Home page, Login page,
Registration page,
Left frame : At least four links for navigation, which will display the catalogue of
respective links.
For e.g.: When you click the link “CSE” the catalogue for CSE Books should be
displayed in the Right frame.
Right frame: The pages to the links in the left frame must be loaded here. Initially
this page contains description of the web site.
PROGRAM:
Homepage
<head>
<frameset rows="20%,*">
<frame src="topframe.html"name="f1">
<frameset cols="20%,*">
<frame src="leftframe.html"name="f2">
<frame src="rightframe.html"name="f3">
</frameset>
</frameset>
</head>
Top frame:
<html>
<body>
<p>
<img src="C:\Documents and Settings\All Users\Documents\My Pictures\Sample
Pictures\Winter.jpg" align=left width=100 height=100">
<h1 align=center>Online book store</h1>
</p>
<br>
<p>
<h2> nbsp;
<a href="homepage.html" target=_parent>
Leftframe:
<html>
<body>
<a href=cse.html target="f3"><h3>CSE</h3> </a><br><br><br><br><br>
<a href=ece.html target="f3"><h3>ECE</h3></a><br><br><br><br><br>
<a href=eee.html target="f3"><h3>EEE</h3></a><br><br><br><br><br>
<a href=civil.html target="f3"><h3>Civil</h3></a>
</body>
</html>
Right frame:
<html>
<body bgcolor="pink">
<p>
<h2 align="center"> <font face="times new roman" color="green" >Online book store
information </font> </h2>
<h3> <font face="monotype corsiva" color=blue> This is
the online book store developed by students of pvpsit.It contains book catalogue of various
branches like cse,ece,eee,civil </font></h3>
</p>
</body>
OUTPUT:
2) LOGIN PAGE
DESCRIPTION:
The login page contains the user name and the password of the user to
authenticate.
PROGRAM:
<html>
<head>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body background=”E:\1.jpg”>
<form action="index.jsp" method="get">
<label>
DESCRIPTION:
The catalogue page should contain the details of all the books available in the web
site in a table.
The details should contain the following:
PROGRAM:
<html>
<body>
<center>
<table border=1>
<tr>
<th> Book Preview </th>
<th> Book Details </th>
<th> Price </th>
<th> Payment </th>
</tr>
<tr>
<td> <img src="C:\Documents and Settings\All users\My Documents\My Pictures\xml.bmp"
width=100 height=50>
</img>
</td>
<td>
<pre>
<font face="comic sans ms" size=4 color="green" >
book:XML Bible
Author:winston
Publisher:Wiesley
</font>
</pre>
</td>
<td> $40 </td>
4) CART PAGE
DESCRIPTION:
The cart page contains the details about the books which are added to the cart.
PROGRAM:
<html>
<body>
<center><br><br><br>
<img src=”E:\aa.jpg”>
<table border=1 cellpadding=center>
<thead>
<tr>
<th>Book name</th>
<th>price</th>
<th>quantity</th>
<th>amount</th>
</tr>
</thead>
<tr>
<td>java 2</td>
<td>$45</td>
<td>2</td>
<td>$70</td>
</tr>
<tr>
<td> XML bible</td>
OUTPUT:
DESCRIPTION:
Create a “registration form “with the following fields
1)Name(Textfield)
2) Password (password field)
3) E-mail id (text field)
4) Phone number (text field)
5) Sex (radio button)
6) Date of birth (3 select boxes)
7) Languages known (check boxes – English, Telugu, Hindi, Tamil)
8) Address (text area)
PROGRAM:
<html>
<body>
<center>
<img src=”E:\aaa.jpg” align=”left”>
<form>
<label>name</label>
<input type="text" size="20"><br><br> <br>
<label>password</label>
<input type="password" size="20" maxsize="28"><br> <br> <br>
<label>email</label>
<input type="text" size="30"><br> <br> <br>
<label>phone no</label>
<input type="text" size="2">
<input type="text" size="6">
<input type="text" size="10"><br> <br> <br>
<label>Sex</label>
<input type="radio" name="sex">m
RESULT:
Thus the registration and cart pages for online book store pages are created
successfully
PROGRAM:
Valid.js
function fun()
{
var userv=document.forms[0].user.value;
var pwdv=document.forms[0].pwd.value;
var emailv=document.forms[0].email.value;
var phv=document.forms[0].ph.value;
var userreg=new RegExp("^[a-zA-Z][a-zA-Z0-9]*$");
var emailreg=new RegExp("^[a-zA-Z][a-zA-Z0-9_.]*@[a-zA-Z][a-zA-Z0-9_.]*.
[a-zA-Z][a-zA-Z0-9_.]{2}.[a-zA-Z][a-zA-Z0-9_.]{2}$|^[a-zA-Z][a-zA-Z0-9_.]*@[a-zA-
Z][a-zA-Z0-9_.]*.[a-zA-Z][a-zA-Z0-9_.]{3}$");
var phreg=new RegExp("^[0-9]{10}$");
var ruser=userreg.exec(userv);
var remail=emailreg.exec(emailv);
}
Register.html
<html>
<body>
<center>
<fieldset>
<legend>Registration</legend>
<form action="Database" method="get" onSubmit="return fun()">
<pre>
Name :<input type="text" name="user" size="10"><br>
Password :<input type="password" name="pwd" size="10"><br>
E-mail :<input type="text" name="email" size="10"><br>
Phone Number :<input type="text" name="ph" size="10"><br>
<input type="submit" value="Register">
</pre>
</form>
</body>
<script src="valid.js"></script>
</html>
OUTPUT:
DESCRIPTION:
Syntax
The CSS syntax is made up of three parts: a selector, a property and a value:
selector {property: value}
The selector is normally the HTML element/tag you wish to define, the property is the
attribute you wish to change, and each property can take a value. The property and value
are separated by a colon, and surrounded by curly braces:
body {color: black}
External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an
external style sheet, you can change the look of an entire Web site by changing one file.
Each page must link to the style sheet using the <link> tag. The <link> tag goes inside
the head section:
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css" />
</head>
The browser will read the style definitions from the file mystyle.css, and format the
document according to it.
Internal Style Sheet
An internal style sheet should be used when a single document has a unique style.
You define internal styles in the head section by using the <style> tag,
<head>
<style>
selector {property:value; property:value;…..}
PROGRAM:
Cas.css:
a:link{color:black;}
a:visited{color:pink;}
a:active{color:red;}
a:hover{color:green;}
.right {
text-align:center;
text-decoration:underline;
font-weight:bold;
color:blue;
font-family:comic sans ms;
font-size:30; }
.image {
text-align:left;
font-family:"monotype corsiva";
font-weight:10;
}
htm.html:
<html>
<head>
<link rel="stylesheet" href="cas.css" type="text/css">
<style>
.xlink{ text-decoration:none;font-weight:bold;cursor:crosshair;}
.ylink{text-decoration:underline;font-weight:bold;cursor:help;}
</style>
</head>
<body class="image">
<p style="text-align:right;">
<a href="registration.html" class="xlink"> Reg Link</a>
<a href="topframe.html" class="ylink"> Help Link</a>
</p>
<p class="right">PVPSIT</p>
<div style="position:relative;font-size:90px;z-index:5;color:purple;">PVPSIT</div>
<div style="position:relative;font-size:50px;z-index:1;top:-70; left:5;color:blue;">CSE</div>
<div style="position:relative;font-size:90px;z-index:1;color:purple;">PVPSIT</div>
OUTPUT:
RESULT: Thus different style of CSS and different type of the properties are applied.
DESCRIPTION:
PROGRAM:
XML document (bookstore.xml)
<bookstore>
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
Bookstore.xml
<!DOCTYPE bookstore SYSTEM "C:\Documents and Settings\Administrator\My
Documents\bookstore.dtd">
<bookstore>
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Bookstore.xml
<bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\My
Documents\bookstore.xsd">
<book>
<title>web programming</title>
<author>chrisbates</author>
<ISBN>123-456-789</ISBN>
<publisher>wiley</publisher>
<edition>3</edition>
<price>350</price>
</book>
<book>
<title>internet worldwideweb</title>
<author>ditel&ditel</author>
<ISBN>123-456-781</ISBN>
<publisher>person</publisher>
<edition>3</edition>
<price>450</price>
</book>
</bookstore>
PROGRAM:
XML:
<?xml version="1.0"?>
<bookstore>
<book>
<title>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2> My Books collection</h2>
<table border="1">
<tr bgcolor="red">
<th align="left">title</th>
DESCRIPTION:
A Bean is a JavaBeans component. Beans are independent, reusable software
modules. Beans may be visible objects, like AWT components, or invisible objects, like
queues and stacks. A builder/integration tool manipulates Beans to create applets and
applications.
Beans consist of three things:
PROGRAM:
package sunw.demo.colors;
import java.awt.*;
import java.awt.event.*;
public class Colors extends Canvas
{
transient private Color color;
private boolean rectangular;
public Colors()
{
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent me){
change(); }
});
rectangular=false;
setSize(100,100);
change();
}
public boolean getRectangular()
{
return rectangular;
}
public void setRectangular(boolean flag)
{
this.rectangular=flag;
RESULT:
Program 2:
public convert()
{
setSize(100,1000);
}
public double getDollars()
{
return dollars;
}
public void setDollars(double value)
{
this.dollars=value;
}
public void setRupees(double value)
{
this.rupees=value;
}
public double getRupees()
{
return rupees;
}
public void change()
{
dollarvalue= value();
repaint();
}
private double value()
{
return rupees*dollars;
}
Convert.mf
Name: sunw/demo/convert/convert.class
Java-Bean: True ( press Enter)
(Carriage return compulsory)
Program 3:
package sunw.demo.colors;
import java.awt.*;
import java.awt.event.*;
public class mouseclick extends Canvas {
public int count=0;
public mouseclick() {
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
change();
}
});
Mouseclick.mft
Name: sunw/demo/colors/mouseclick.class
Java-Bean: True
Output
DESCRIPTION:
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.
On Windows XP, you could also go to the Start menu, select Control Panel, choose
System, click on the Advanced tab, press the Environment Variables button at the
bottom, and enter the JAVA_HOME variable and value directly as:
Name: JAVA_HOME
Value: C:\jdk
OUTPUT:
OUTPUT
DESCRIPTION:
Servlet Life cycle:
1. Servlet class loading
2. Servlet Instantiation
3. call the init method
4. call the service method
5. call destroy method
Class loading and instantiation
If you consider a servlet to be just like any other Java program, except that it runs
within a servlet container, there has to be a process of loading the class and making it
ready for requests. Servlets do not have the exact equivalent of a main method that causes
them to start execution.
When a web container starts it searches for the deployment descriptor
(WEB.XML) for each of its web applications. When it finds a servlet in the descriptor it
will create an instance of the servlet class. At this point the class is considered to be
loaded (but not initialized).
void destroy()
PROGRAM:
cologin.html:
<html>
<head>
<title> login Page </title>
<p style= "background:yellow; top:100px; left:250px; position:absolute; ">
</head>
<body>
<form ACTION="clogin">
Addcook.java:
import javax.servlet.* ;
import javax.servlet.http.*;
import java.io.*;
public class Addcook extends HttpServlet
{
OUTPUT:
user2=sc.getInitParameter("username2");
pwd2=sc.getInitParameter("password2");
user3=sc.getInitParameter("username3");
pwd3=sc.getInitParameter("password3");
user4=sc.getInitParameter("username4");
pwd4=sc.getInitParameter("password4");
}
Public void service(ServletRequest req,ServletResponse res)throws
ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
user5=req.getParameter("user");
pwd5=req.getParameter("pwd");
if((user5.equals(user1)&&pwd5.equals(pwd1))||(user5.equals(user2)&&pwd5.equals(pwd2))||
(user5.equals(user3)&&pwd5.equals(pwd3))||(user5.equals(user4)&&pwd5.equals(pwd4)))
web.xml:
<web-app>
<servlet>
<servlet-name>Example</servlet-name>
<servlet-class>Example1</servlet-class>
<init-param>
<param-name>username1</param-name>
<param-value>pvpsit</param-value>
</init-param>
<init-param>
<param-name>password1</param-name>
<param-value>cse</param-value>
</init-param>
<init-param>
<param-name>username2</param-name>
<param-value>1234</param-value>
</init-param>
<init-param>
<param-name>password2</param-name>
<param-value>4567</param-value>
</init-param>
<init-param>
<param-name>username3</param-name>
<param-value>cse</param-value>
</init-param>
OUTPUT:
DESCRIPTION:
PROGRAM:
Registration.html:
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor="#00FFFf">
<form METHOD="POST" ACTION="register">
<CENTER>
<table>
<center>
<tr> <td> Username </td>
<td><input type="text" name="usr"> </td> </tr>
<tr><td> Password </td>
<td><input type="password" name="pwd"> </td> </tr>
<tr><td>Age</td>
<td><input type="text" name="age"> </td> </tr>
<tr> <td>Address</td>
<td> <input type="text" name="add"> </td> </tr>
<tr> <td>email</td>
<td> <input type="text" name="mail"> </td> </tr>
<tr> <td>Phone</td>
<td> <input type="text" name="phone"> </td> </tr>
Login.html
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor=pink> <center> <table>
<form METHOD="POST" ACTION="authent">
<tr> <td> Username </td>
<td><input type="text" name="usr"></td> </tr>
<tr> <td> Password </td>
<td> <input type="password" name="pwd"> </td> </tr>
<tr> <td align=center colspan="2"><input type="submit" value="submit"></td> </tr>
</table> </center>
</form>
</body>
</html>
Ini.java:
import javax.servlet.*;
import java.sql.*;
import java.io.*;
public class Ini extends GenericServlet
{
private String user1,pwd1,email1;
OUTPUT:
DESCRIPTION:
JSP scripting elements let you insert Java code into the servlet that will be generated
from the current JSP page. There are three forms:
1. Expressions of the form <%= expression %> that are evaluated and inserted into
the output,
2. Scriptlets of the form <% code %> that are inserted into the servlet's service
method, and
3. Declarations of the form <%! code %> that are inserted into the body of the
servlet class, outside of any existing methods.
Each of these is described in more detail below.
JSP Expressions
A JSP expression is used to insert Java values directly into the output. It has the
following form:
<%= Java Expression %>
The Java expression is evaluated, converted to a string, and inserted in the page. This
evaluation is performed at run-time (when the page is requested), and thus has full access
to information about the request. For example, the following shows the date/time that the
page was requested:
Current time: <%= new java.util.Date() %>
To simplify these expressions, there are a number of predefined variables that you can
use. These implicit objects are discussed in more detail later, but for the purpose of
expressions, the most important ones are:
The user is authenticated when he submits the login form using the user name and
password from the database.
PROGRAM:
Retrieve.java:
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
import java.util.*;
public class Retrieve extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res) throws
ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@195.100.101.158:1521:cclab","scott","tiger");
Statement s=con.createStatement();
ResultSet r=s.executeQuery("select * from cart");
out.println("<center> <table border=1>");
catch(ClassNotFoundException cl)
{
out.println("class not found"+cl);
}
}
}
web.xml:
<web-app>
<servlet>
<servlet-name>set</servlet-name>
<servlet-class>Cartenter</servlet-class>
</servlet>
<servlet>
RESULT:
The data is extracted from the tables and displayed in the catalogue page using JDBC
There are numerous methods available for session Object. Some are:
getAttribute(String name)
getAttributeNames
isNew()
getCreationTime
getId
invalidate()
getLastAccessedTime
getMaxInactiveInterval
removeAttribute(String name)
setAttribute(String, object)
The <jsp:include> element allows you to include either static and dynamic files in a JSP
file.
Program :
Cart .java
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class Cart extends HttpServlet
{
}
public void service(HttpServletRequest
req,HttpServletResponse res) throws
IOException,ServletException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
HttpSession hs=req.getSession();
ArrayList cart=(ArrayList)hs.getAttribute("cart");
if(cart==null)
{
pw.println("No items in your cart");
cart=new ArrayList();
hs.setAttribute("cart",cart);
}
String itemselected[];
String item;
itemselected=req.getParameterValues("book");
if(itemselected!=null)
{
for(int i=0;i<itemselected.length;i++)
{
item=itemselected[i];
cart.add(item);
}}
}
}
Catalogue.java
import java.util.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class Catalogue extends HttpServlet
{
int itemcount=0;
public void init(ServletConfig config) throws
ServletException
{
super.init(config);
}
public void service(HttpServletRequest
req,HttpServletResponse res) throws
IOException,ServletException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
HttpSession hs=req.getSession();
ArrayList cart=(ArrayList)hs.getAttribute("cart");
if(cart!=null)
{
itemcount=cart.size();
}
pw.println("<body><center><fieldset><legend>Catalogue</leg
end><form action='cart' method='get'><input
type='checkbox' value='Java2'
name='book'>java2</input><br>");
pw.println("<input type='checkbox' name='book'
value='web programming'>Web
programming</input><br>");
pw.println("<input type='checkbox' name='book'
value='Java2 Complete Reference'>Java2 Complete
Reference</input><br>");
pw.println("<input type='checkbox' name='book'
value='Internet & World wide web'>Internet & World wide
web</input><br>");
pw.println("<input type='checkbox' name='book'
value='Core servlets &JSP'>Core servlets
&JSP</input><br>");
pw.println("<input type='checkbox' name='book'
value='J2EE 3rd edition'>J2EE 3rd edition</input><br>");
pw.println("<input type='checkbox' name='book'
value='Electronic Devices and circuits'>Electronic Devices and
circuits</input><br>");
pw.println("<input type='checkbox' name='book'
value='Software Engineering'>Software
Engineering</input><br>");
pw.println("<input type='checkbox' name='book'
value='software project management'>software project
management</input><br>");
pw.println("<input type='checkbox' name='book'
value='Computer networks'>Computer
networks</input><br>");
pw.println("</fieldset></center>");
}
}
<web-app>
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
<init-param>
<param-name>username</param-name>
<param-value>syam</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>syam</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/login.do</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>cat</servlet-name>
<servlet-class>Catalogue</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>cat</servlet-name>
Week 13:
Description :
Model-View-Controller Pattern
Because of this separation, multiple views and controllers can interface with the same
model. Even new types of views and controllers that never existed before can interface
with a model without forcing a change in the model design.
How It Works
A Concrete Example
We explain the MVC pattern with the help of a simple spinner component which
consists of a text field and two arrow buttons that can be used to increment or decrement
a numeric value shown in the text field. We currently do not have an element type that
can directly represent a spinner component, but it easy is to synthesize a spinner using
existing element types.
Depending on the source of the event, the ultimate action listener either increments or
decrements the value held in the model — The action listener is an example of a
controller.
The trampolines that initially receive the action events fired by the arrow buttons, are
also controllers — However, instead of modifying the spinner’s model directly, they
delegate the task to a separate controller (action listener).
Multiple Controllers
The MVC pattern allows any number of controllers to modify the same model. While
we have so far focused only on the two arrow buttons as likely source of events, there is,
in fact, a third event source in this example — Whenever the text field has focus, hitting
the enter key fires off an action event that may potentially be handled by a different
action listener than the one handling action events from the buttons.
Program :
ShoppingServlet.java:
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import shopping.BOOK;
if (session == null) {
res.sendRedirect("/error.html");
}
Vector buylist=(Vector)session.getValue("shopping.shoppingcart");
String action = req.getParameter("action");
if (!action.equals("CHECKOUT")) {
if (action.equals("DELETE")) {
String del = req.getParameter("delindex");
int d = (new Integer(del)).intValue();
buylist.removeElementAt(d);
} else if (action.equals("ADD")) {
boolean match=false;
BOOK aCD = getBOOK(req);
if (buylist==null) {
buylist = new Vector(); //first order
buylist.addElement(aCD);
} else { // not first buy
for (int i=0; i< buylist.size(); i++) {
BOOK cd = (BOOK) buylist.elementAt(i);
if (cd.getTitle().equals(aCD.getTitle())) {
cd.setQuantity(cd.getQuantity()+aCD.getQuantity());
buylist.setElementAt(cd,i);
match = true;
Experiment :14
Description :
Program :
First.jsp
<%@ taglib uri="hello" prefix="examples"%>
<html>
<head>
Web.xml
<web-app>
<taglib>
<taglib-uri>hello</taglib-uri>
<taglib-location>/WEB-INF/tlds/hello.tld</taglib-location>
</taglib>
</web-app>
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<tag>
<name>hello</name>
<tag-class>tagext.HelloTag</tag-class>
<body-content>JSP</body-content>
</tag>
</taglib>
package tagext;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.TagSupport;
import java.util.*;
public class HelloTag extends TagSupport
{
public int doStartTag()
{
return EVAL_BODY_INCLUDE;
}
public int doEndTag()
{
Date date=new Date();
try
{
pageContext.getOut().write("HellOWorld");
pageContext.getOut().write("My name is :"+getClass().getName()+"and
it's"+date);
}catch(Exception e){}
return EVAL_PAGE;
}
}
Output
Experiment No : 14
Description:
Implementation:
Step 1:
Step 2:
Step 4:
step 7:
step 9:
Q: After I have edited an HTML file, I cannot view the result in my browser.
Why?
A: Make sure that you have saved the file with a proper name and extension like
"c:\mypage.htm". Also make sure that you use the same name when you open
the file in your browser.
Q: I have edited an HTML file, but the changes don't show in the browser.
Why?
A: A browser caches pages so it doesn't have to read the same page twice. When
you have modified a page, the browser doesn't know that. Use the browser's
refresh/reload button to force the browser to reload the page.
1. What is XML?
(ans) XML is the Extensible Markup Language. It improves the functionality of the Web
by letting you identify your information in a more accurate, flexible, and adaptable way.
It is extensible because it is not a fixed format like HTML (which is a single, predefined
markup language). Instead, XML is actually a metalanguage—a language for describing
other languages—which lets you design your own markup languages for limitless
different types of documents. XML can do this because it's written in SGML, the
international standard metalanguage for text document markup (ISO 8879).
4. What is SGML?
(ans)SGML is the Standard Generalized Markup Language (ISO 8879:1986), the
international standard for defining descriptions of the structure of different types of
electronic document. There is an SGML FAQ from David Megginson at
http://math.albany.edu:8800/hm/sgml/cts-faq.htm
SGML is very large, powerful, and complex. It has been in heavy industrial and
commercial use for nearly two decades, and there is a significant body of expertise and
software to go with it.
XML is a lightweight cut-down version of SGML which keeps enough of its
functionality to make it useful but removes all the optional features which made SGML
too complex to program for in a Web environment.
5. What is HTML?
(ANS)HTML is the HyperText Markup Language (RFC 1866), which started as a small
application of question A.4, SGML for the Web, originating with Tim Berners-Lee at
CERN in 1989–90.
XML is a markup specification language with which you can design ways of describing
information (text or data), usually for storage, transmission, or processing by a program.
It says nothing about what you should do with the data (although your choice of element
names may hint at what they are for):
<part num="DA42" models="LS AR DF HG KJ"
update="2001-11-22">
<name>Camshaft end bearing retention circlip</name>
<image drawing="RR98-dh37" type="SVG" x="476"
y="226"/>
<maker id="RQ778">Ringtown Fasteners Ltd</maker>
<notes>Angle-nosed insertion tool <tool
id="GH25"/> is required for the removal
and replacement of this part.</notes>
</part>
On its own, an SGML or XML file (including HTML) doesn't do anything. It's a data
format which just sits there until you run a program which does something with it. See
also the question about how to run or execute XML files.
A: A servlet session is created and stored on the server side. The servlet container
keeps track of all the sessions it manages and fulfils servlet API requests to get
HttpSessions, manipulate object data stored with them and trigger event
callbacks.
To the maintain the session, Web clients must pass back a valid session identifier
as a cookie header value or dynamically generated URL parameter. In this sense,
the session is also stored by the client, but only as a token reference.
Q: Can I create a session with GenericServlet?
A: First, it is best to use a single servlet to handle each form submission. A single
servlet for all input would be too complicated. Give each servlet responsibility to
validate a single form input, and pass the error cases on to JSP documents that
explain the problem and allow users to amend the input.
Servlet concepts
Q: What's the difference between applets and servlets?
Applets are essentially graphical user interface (GUI) applications that run on the
client side in a network environment, typically embedded in an HTML page.
Applets are normally based on Abstract Windowing Toolkit components to
maintain backward-compatibility with the widest range of browsers' Java
implementations. The application classes are downloaded to the client and run in
a Java Virtual Machine provided by the browser, in a restrictive security
environment called a "sandbox".
Servlets are used to dynamically generate HTTP responses and return HTML
content to Web browsers on the server side. Servlets are often used to validate and
process HTML form submissions and control a series of user interactions in what
is known as a Web application. Servlets can be used to control all aspects of the
request and response exchange between a Web browser and the server, called a
servlet container.
Q: How can I write a servlet using Javascript?
A: Java servlets is a server side technology that delivers dynamic content to Web
browsers and other clients. Javascript is also delivered by a Web server, but the
code is only interpreted and executed after it has been downloaded by the Web
browser. This means that it is not possible to write servlet code in Javascript.
It is possible to include Javascript in the output of servlets and Java Server Pages,
just like standard Web pages. It is also possible to dynamically generate
A: Servlets are standard Java classes and are executed by the Java Virtual
Machine in exactly the same way as any other. However, the environment or
context in which servlets are executed is different. A servlet is not invoked
directly through a main method, the class is loaded and run by a servlet container.
A: Any Java class can be used in a Web application, provided you make the
classes available to the servlet container at runtime. The Java API classes can be
used directly by adding import statements to your servlet class. Other supporting
classes can also be imported, but these classes must be added to the classes or
lib directory of your application.
If you need to configure the supporting classes, this can be done with standard
servlet configuration features using the ServletConfig and ServletContext
objects available to the init(ServletConfig) method.
Q: How can I tell when a servlet is instantiated?
Q: What is URL-rewriting?
A: There are four main alternatives to full session-based transfer of data values,
two of them use features of the session tracking API: cookies and URL-rewriting,
detailed below.
What is JavaServer Pages technology?
JSP pages use XML tags and scriptlets written in the Java programming
language to encapsulate the logic that generates the content for the page. It
passes any formatting (HTML or XML) tags directly back to the response
page. In this way, JSP pages separate the page logic from its design and
display.
JSP technology is part of the Java technology family. JSP pages are
compiled into servlets and may call JavaBeans components (beans) or
Enterprise JavaBeans components (enterprise beans) to perform
processing on the server. As such, JSP technology is a key component in a
highly scalable architecture for web-based applications.
JSP pages are not restricted to any specific platform or web server. The
JSP specification represents a broad spectrum of industry input.
What is a servlet?
JSP pages are compiled into servlets, so theoretically you could write
servlets to support your web-based applications. However, JSP technology
was designed to simplify the process of creating pages by separating web
presentation from web content. In many applications, the response sent to
the client is a combination of template data and dynamically-generated
Where can I get the most current version of the JSP specification?
How does the JSP specification relate to the Java Enterprise Edition 5 Platform?