Java Journal
Java Journal
: 01 Date:
Experiment Title: Write a Java program to implement fixed and dynamic stack using interface.
Objectives: To demonstrate the benefits/ applications of using interface in Java program.
Software’s used:
The interface in Java is a mechanism to achieve abstraction. There can be only abstract methods in the
Java interface, not method body. It is used to achieve abstraction and multiple inheritance in Java. Using
the keyword interface, you can fully abstract a class’ interface from its implementation. That is, using
interface, you can specify what a class must do, but not how it does it. Interfaces are syntactically similar
to classes, but they lack instance variables, and their methods are declared without any body.
To implement an interface, a class must create the complete set of methods defined by the
interface. Interfaces are designed to support dynamic method resolution at run time. Normally, in order
for a method to be called from one class to another, both classes need to be present at compile time so the
Java compiler can check to ensure that the method signatures are compatible.
Syntax
access interface name
{
return-type method-name1(parameter-list);
return-type method-name2(parameter-list);
type final-varname1 = value;
type final-varname2 = value;
return-type method-nameN(parameter-list);
type final-varnameN = value;
}
The general form of a class that includes the implements clause looks like this:
class classname [extends superclass] [implements interface [,interface...]]
{
// class-body
}
In the given experiment Interface is created and two classes namely fixed stack and dynamic stack are
going to implement the methods of interface.
Algorithm/Procedure:
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
An exception is an abnormal condition that arises in a code sequence at run time. In other words, an
exception is a runtime error.
Java exception handling is managed via five keywords: try, catch, throw, throws, and finally.
All exception types are subclasses of the built-in class Throw able. Thus, Throw able is at the top of the
exception class hierarchy. Immediately below Throw able are two subclasses that partition exceptions
into two distinct branches. One branch is headed by Exception. This class is used for exceptional
conditions that user programs should catch. This is also the class that you will subclass to create your own
custom exception types. There is an important subclass of Exception, called Runtime Exception.
Exceptions of this type are automatically defined for the programs that you write and include things such
as division by zero and invalid array indexing.
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
Objectives: To demonstrate the concept of client and server model using servlet and also to read the
form data in different ways which is been sent by the client.
Software’s used:
Servlets are programs that run on a Web or application server and act as a middle layer between a requests
coming from a Web browser or other HTTP client and databases or applications on the HTTP server.
Job/Role of Servlets.
Read the explicit data sent by the client
Read the explicit data sent by the client
Generate the results.
Send the explicit data (i.e., the document) to the client.
Send the implicit HTTP response data.
import java.io. *;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletTemplate extends HttpServlet
{public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{// Use "request" to read incoming HTTP headers //
PrintWriter out = response.getWriter();
// Use "out" to send content to browser.}}
Algorithm/Procedure:
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
Java Sever Pages are used to validate the user credentials. JSP technology is used to create web
application just like Servlet technology. It can be thought of as an extension to Servlet because it provides
more functionality than servlet such as expression language, JSTL, etc.
A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than Servlet
because we can separate designing and development. It provides some additional features such as
Expression Language, Custom Tags, etc.
Algorithm/Procedure:
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
Objectives: To demonstrate the action tags for handling the client request using multiple pages in an
application.
Software’s used:
JSP Action Tags: There are many JSP action tags or elements. Each JSP action tag is used to perform
some specific tasks. The action tags are used to control the flow between pages and to use Java Bean.
jsp:include: The jsp:include action tag is used to include the content of another resource it may
be jsp, html or servlet.
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
A JSP directive affects the overall structure of the servlet that results from the JSP page
In JSP, there are three main types of directives: page, include, and taglib. A page directive can be placed
anywhere within the document;
The second directive, include, lets you insert a file into the JSP page at the time the JSP file is translated
into a servlet An include directive should be placed in the document at the point at which you want the
file to be inserted; The third directive, taglib, defines custom markup tags;
Info
Language
Session
Error page
Is error page
Content type
Algorithm/Procedure:
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
JavaBean
JavaBean Properties:
A JavaBean property is a named feature that can be accessed by the user of the object. The feature can be
of any Java data type, containing the classes that you define.
A JavaBean property may be read, write, read-only, or write-only. JavaBean features are accessed through
two methods in the JavaBean's implementation class:
1. getPropertyName ()
For example, if the property name is firstName, the method name would be getFirstName() to read that
property. This method is called the accessor.
2. setPropertyName ()
For example, if the property name is firstName, the method name would be setFirstName() to write that
property. This method is called the mutator.
Syntax:
</jsp:useBean>
useBean tag which is a built in tag from JSP to read, write and to populate the Bean class which
encapsulates many objects in only one single object.
Algorithm/Procedure:
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
Software’s used:
A cookie is a small piece of information that is persisted between the multiple client requests.
A cookie has a name, a single value, and optional attributes such as a comment, path and domain
qualifiers, a maximum age, and a version number.
Cookie class
javax.servlet.http.Cookie class provides the functionality of using cookies. It provides a lot of useful
methods for cookies.
Constructor Description
Cookie(String name, String value) constructs a cookie with a specified name and value.
Useful Methods of Cookie class
There are given some commonly used methods of the Cookie class.
Method Description
public void setMaxAge(int expiry) Sets the maximum age of the cookie in seconds.
public String getName() Returns the name of the cookie. The name cannot be changed
after creation.
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total
Software’s used:
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query
with the database. It is a part of Java SE (Java Standard Edition). JDBC API uses JDBC drivers to
connect with the database. There are four types of JDBC drivers:
o JDBC-ODBC Bridge Driver,
o Native Driver,
o Network Protocol Driver, and
o Thin Driver
Result:
Learning Conclusion:
Marks Alloted:
Activity Marks
1. Conduction & Execution (Max Marks: 5)
2. Viva for the Experiment (Max Marks: 5)
3. Lab record Writeup (Max Marks: 5)
Total