Você está na página 1de 4

Title: Study of Java Server Pages(JSP)

Roll:61

INTRODUCTION
Java Server Pages (JSP) is a Java technology that helps software developers serve
dynamically generated web pages based on HTML, XML, or other document types.
Released in 1999 as Sun's answer to ASP and PHP, JSP was designed to address the
perception that the Java programming environment didn't provide developers with
enough support for the Web.

OVERVIEW
Architecturally, JSP may be viewed as a high-level abstraction of Java servlets. JSP
pages are loaded in the server and operated from a structured special installed Java server
packet called a Java EE Web Application, often packaged as a .war or .ear file archive.

JSP allows Java code and certain pre-defined actions to be interleaved with static web
markup content, with the resulting page being compiled and executed on the server to
deliver an HTML or XML document. The compiled pages and any dependent Java
libraries use Java byte code rather than a native software format.

JSP syntax is a fluid mix of two basic content forms: scriptlet elements and markup.
Markup is typically standard HTML or XML, while scriptlet elements are delimited
blocks of Java code which may be intermixed with the markup.

The JSP syntax adds additional XML-like tags, called JSP actions, to invoke built-in
functionality. Additionally, the technology allows for the creation of JSP tag libraries that
act as extensions to the standard HTML or XML tags. JVM operated tag libraries provide
a platform independent way of extending the capabilities of a web server.

What can a JavaScript do?


• JavaScript gives HTML designers a programming tool - HTML authors are
normally not programmers, but JavaScript is a scripting language with a very
simple syntax! Almost anyone can put small "snippets" of code into their HTML
pages
• JavaScript can put dynamic text into an HTML page - A JavaScript statement
like this: document write ("<h1>" + name + "</h1>") can write a variable text
into an HTML page
• JavaScript can react to events - A JavaScript can be set to execute when
something happens, like when a page has finished loading or when a user clicks
on an HTML element
• JavaScript can read and write HTML elements - A JavaScript can read and
change the content of an HTML element
• JavaScript can be used to validate data - A JavaScript can be used to validate
form data before it is submitted to a server. This saves the server from extra
processing
• JavaScript can be used to detect the visitor's browser - A JavaScript can be
used to detect the visitor's browser, and - depending on the browser - load another
page specifically designed for that browser
• JavaScript can be used to create cookies - A JavaScript can be used to store and
retrieve information on the visitor's computer

Why use JSP?


JSP is easy to learn and allows developers to quickly produce web sites and applications
in an open and standard way. JSP is based on Java,an object-oriented language. JSP
offers a robust platform for web development.

Main reasons to use JSP:

Multi platform.
Component reuse by using Javabeans and EJB.
Advantages of Java.

You can take one JSP file and move it to another platform,web server or JSP Servlet
engine.
This means you are never locked into one vendor or platform.

HTML and graphics displayed on the web browser are classed as the presentation layer.
The Java code (JSP) on the server is classed as the implementation.

By having a separation of presentation and implementation, web designers work only on


the presentation and Java developers concentrate on implementing the application.

JSP architecture
JSPs are built on top of SUN Microsystems servlet technology. JSPs are essential an
HTML page with special JSP tags embedded. These JSP tags can contain Java code. The
JSP file extension is .jsp rather than .htm or .html. The JSP engine parses the .jsp and
creates a Java servlet source file. It then compiles the source file into a class file,this is
done the first time and this why the JSP is probably slower the first time it is accessed.
Any time after this the special compiled servlet is executed and is therefore returns faster.
Creating your first JSP page
<html>
<head>
<title>My first JSP page
</title>
</head>
<body>
<%@ page language="java" %>
<% out.println("Hello World"); %>
</body>
</html>

Type the code above into a text file. Name the file helloworld.jsp.
Place this in the correct directory on your JSP web server and call it via your browser.

Você também pode gostar