0% found this document useful (0 votes)
130 views5 pages

WTL Assignment No.6.

The document outlines an assignment to design and develop a web application using JSP, Servlet, and MySQL. Specifically, students are asked to create a database table to store student information using MySQL and display the table contents using JSP. The key outcomes are to develop a dynamic webpage using JSP, HTML, and Servlet, write a Servlet to process form data and store it in a MySQL database, and write a JSP to catch form data and store it in MySQL. The document provides background on JSP, Servlets, and MySQL to complete the assignment.

Uploaded by

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

WTL Assignment No.6.

The document outlines an assignment to design and develop a web application using JSP, Servlet, and MySQL. Specifically, students are asked to create a database table to store student information using MySQL and display the table contents using JSP. The key outcomes are to develop a dynamic webpage using JSP, HTML, and Servlet, write a Servlet to process form data and store it in a MySQL database, and write a JSP to catch form data and store it in MySQL. The document provides background on JSP, Servlets, and MySQL to complete the assignment.

Uploaded by

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

Department of Computer Engineering Subject: Web Technology Laboratory

Expected Date of Completion…………………………………

Actual Date of Completion:………………………….

Assignment No: 6
Title: Design and develop suitable web application using JSP, Servlet and MySQL (Backend).
Objective:

1. Understand about basic concepts of html, CSS


2. Understand the basic functionalities of JSP
3. Having the knowledge of SQL query to create the database

Problem Statement
Implement the program demonstrating the use of JSP.
e.g., Create a database table student info (stud id, stud name, class, division, city) using database
like Oracle/MySQL etc. and display (use SQL select query) the table content using JSP.

Outcomes

1. Develop a dynamic webpage using JSP, HTML and Servlet.


2. Write a server-side java application called Servlet to catch the data sent from client, process it
and store it on database (MySQL).
3. Write a server-side java application called JSP to catch form data sent from client and store it
on database (MySQL).

Software and Hardware requirement


1. Any Operating System
2. JDK 7or later
3. Editors; Netbeans/Eclipse
4. Web browser
5. Tomcat 7 or later

Theory
Java Server Pages (JSP): It is a server-side programming technology that is used to create
dynamic web-based applications. JSP have right to use the complete Java APIs, including the
JDBC API to access the databases. It is a technology that helps software developers to create
dynamic web pages based on HTML, XML and other document types.
It was released in 1999 by Sun Microsystems. It is just like a PHP and ASP, but it uses the Java
programming language. A JSP element is a type of java servlet that is designed to accomplish the
role of a user interface for a java web application. Web developers write JSPs as text files that
combine HTML or XHTML code, XML elements, and rooted JSP actions and commands.
Using JSP, you can collect input from users through webpage forms, current records from a
database or another source and create web pages dynamically. JSP tags can be used for different
purposes, such as retrieving information from a database or registering user preferences,
accessing JavaBeans components, passing control between pages, and sharing information
between requests, pages etc.

Why we need JSP?


JSP is used for the design of dynamic web page and servlet is used to code the logic that is
present i.e. in the MVC (Model-View-Controller) architecture, the servlet is the controller and
the JSP is the view.

Architecture of JSP
1. The request / response part of a JSP is defined in below architecture
2. The client-initiated request for a JSP file using browser
3. Webs server (i.e, JSP Engine) invokes the JSP file and interpret the JSP file produce a java
code. The created java code will be a Servlet.
4. Once Servlet is created, JSP engine compiles the servlet. Compilation errors will be detected
in this phase.
5. Now servlet class is loaded by the container and executes it.
6. Engine sends the response back to the client.
Figure: Architecture of JSP
The JSP declaration tag is used to declare fields and methods. The code written inside the jsp
declaration tag is placed outside the service () method of auto generated servlet.

Syntax of JSP declaration tag:


<% Text %>
Example of JSP:
<html>
<head>
<title> JSP File </title>
</head>
<body>
<% out.println (“Welcome to JSP class”)%>
</body>
</html>
Output: Welcome to JSP class

Servlet:
A servlet is server-side programming language in Java. Servlet is web component that is
deployed on the server for creating the dynamic web content/page. A java servlet is a java
program that extends the capabilities of a server. Although server can respond to any types of
requests they must commonly executes application hosted on web server.

Advantages of a Servlet:
• Servlets provide component based and platform-independent methods for building Web based
applications.
• Each Request is run in a separate thread, so servlet request processing is faster than CGI.
• Servlets overcomes the limitations of CGI program.
• Servlets run on Java Virtual Machine and in any platform and it is simple to write.
• Servlet are more powerful and the performance is better.
• Servlets are platform-independent.
• A servlet handles concurrent requests
• Handling HTTP requests and send text and data back to the client is made easy by servlet
request and response objects.

Disadvantages of a Servlet:
• Servlets often contain both business logic and presentation logic so it makes application
difficult to understand.
• You would need JRE to be installed to run a servlet program.

Servlet API:
The Servlet API is supported by all Servlet containers, such as Tomcat and Weblogic, etc. The
Application Programming Interface (API) contains interface and classes to write a servlet
program. The servlet API contains two packages as listed below:
• javax.servlet
• javax.servlet.http

Servlet Lifecycle:
Servlets are small programs that run at server side and creates dynamic web pages. Servlets
respond to any type of requests sent by user. In MVC architecture servlet act as controller. The
controller is the logic that processes and responds to the user requests.
Life Cycle of Servlets contain following steps:
• Load servlet class.
• Create servlet instance.
• Call the init method.
• Call the service method.
• Call the destroy method.

Tools and Techniques


1. JSP and Servlet

2. IDE: NetBeans 7.0 or above

3. Databases: MySQL

NetBeans: It is an IDE used for quickly and easily developing java desktop and mobile and web
applications as well as HTML5 Applications with HTML JavaScript and CSS. Also provides
huge set of tools for PHP and C/C++ developers. It is free and Open-Source tool and has a great
community of users and developers around the world.
MySQL: MySQL is a widely used relational database management system (RDBMS) based on
the Structured Query Language, which is the popular language for accessing and managing the
records in the database. MySQL is free and open-source. MySQL is ideal for both small and
large applications. t is commonly used in conjunction with PHP scripts for creating powerful and
dynamic server-side or web-based enterprise applications.

MySQL supports many Operating Systems like Windows, Linux, MacOS, etc. with C, C++,
and Java languages.

Design and Execution Steps


1. Design html/JSP files with an extension of .html & .JSP.
2. Write Database connection page using Servlet.
3. Set MySQL username, password and Database name in database connection page.
4. Start Tomcat server with port number.
5. Open the browser and type localhost:8084.

Test Cases
Manual Testing is used to validate the student info (stud id, stud name, class, division, city) using
database.

Conclusion
Hence, we have performed the dynamic web application using Servlet and MySQL.

You might also like