Home Database Mysql Tutorial 一个开发人员眼中的JSP技术(上)_MySQL

一个开发人员眼中的JSP技术(上)_MySQL

Jun 01, 2016 pm 02:08 PM
jsp Can develop technology Web page

(作者:天译编译 2000年12月01日 14:26)

JavaServerTM Pages(JSP)技术为我们提供了一种建立动态网页的简单方法,而且也简化了构造web程序的工作。本文从一个开发人员的角度对JSP技术做了一个全面介绍(并提供了一些JSP实例程序)。
前言
JavaServer Pages技术可以让web开发人员和设计人员非常容易的创建和维护动态网页,特别是目前的商业系统。作为JavaTM技术的一部分,JSP能够快速开发出基于web、独立于平台的应用程序。JSP 把用户界面从系统内容中分离开来,使得设计人员能够在不改变底层动态内容的前提下改变整个网页布局。
那么什么是JavaServer Page呢?简单的说,一个JSP网页就是在HTML网页中包含了能够生成动态内容的可执行应用程序代码。此应用程序可能包含JavaBeanTM,JDBCTM对象,Enterprise Java BeanTM (EJB)和Remote Method Invocation (RMI)对象,所有的部分都可以非常容易的从JSP网页上访问到。例如,一个JSP网页可以包含 HTML代码所显示的静态文本和图像,也可以调用一个JDBC对象来访问数据库;当网页显示到用户界面上以后,它将包含静态HTML内容和从数据库中找到相应的动态信息。

  在JSP网页中,要把用户界面和应用程序分开可以考虑在网页设计人员和开发人员之间执行一个非常方便的授权任务。它也允许开发人员去建立灵活的代码,从而非常容易的进行更新和重复利用。由于JSP网页能够根据需要自动进行编译,web设计人员无须重新编译应用程序逻辑就可以改变表述代码。这也使得JSP与Java servlet(它是JavaSever Pages功能的扩展)相比成为一种可以更灵活生成动态web内容的方法。

JSP和Servlet
  如果你已经用过Java servlet,那么你就会知道servlet可以让你建立动态生成的网页,而网页中包含有从服务器方的Java对象中所获得的数据。但是你也得知道servlet 生成网页的方法就是在Java类中嵌入HTML标签和表述代码。这就意味着改变表述代码需要修改和重新编译servlet源文件。因为设计HTML页面的设计人员可能与编写servlet代码的开发人员不是同一个人,更新基于servlet的web应用程序就成了一件非常棘手的事情。

  Enter JavaServer Page是Servlet API的一个扩展。事实上,JSP网页在编译成servlet之前也可以使用,所以它们也具有servlet的所有优势,包括访问Java API。由于JSP 是嵌入到servlet中关于应用程序的一般表述代码,所以他们能够被看成一种“彻底”的servlet。

  JSP网页主要提供了一种建立servlet的高水平方法,它还带来了其他的优点。即使你已经为web应用程序编写了servlet,使用JSP仍然有很多优势:

  JSP网页可以非常容易的与静态模板结合,包括HTML 或XML 片段,以及生成动态内容的代码。

  JSP网页可以在被请求的时候动态的编译成servlet,所以网页的设计人员可以非常容易的对表述代码进行更新。如果需要的话,JSP网页还可以进行预编译。

  为了调用JavaBean组件,JSP标签可以完全管理这些组件,避免网页设计人员复杂化应用程序。

  开发人员可以提供定制化的JSP标签库。

  网页设计人员能够改变和编辑网页的固定模板部分而不影响应用程序。同样,开发人员也无须一个个编辑页面而只须对组件进行合理的改变。

  通常,JSP允许开发人员向许多网页设计人员分发功能性应用程序。这些设计人员也不必知道Java编程语言或任何servlet代码,所以他们能够集中精力去编写HTML代码,而编程人员就可以集中精力去建立对象和应用程序。

建立JSP页面
  粗略看来,JSP网页和HTML (或XML)网页非常相似――都包含用标签封装的文本(在“<>”之间被定义)。当HTML标签被用户的浏览器处理以显示网页的时候,JSP标签能够通过web服务器的处理来生成动态内容。这些JSP标签能够定义个别的操作,比如说用一个方法来调用JavaBean,或者包含标准的Java代码块(也就是所谓的scriptlet),这些代码块能够在网页被访问的时候被执行。

  为了了解它们如何使用,下面我们介绍了一个JSP网页的简单例子,在这个JSP网页中包含了静态HTML内容和从JavaBean生成的动态数据。当用户访问这个网页的时候,它可以显示当前的日期,并根据当前的时间增加相应的问候语(例如“早上好”和“下午好”)。为简单起见,JSP标签显示在块中:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to send web pages to desktop as shortcut in Edge browser? How to send web pages to desktop as shortcut in Edge browser? Mar 14, 2024 pm 05:22 PM

How to send web pages to the desktop as a shortcut in Edge browser? Many of our users want to display frequently used web pages on the desktop as shortcuts for the convenience of directly opening access pages, but they don’t know how to do it. In response to this problem, the editor of this issue will share the solution with the majority of users. , let’s take a look at the content shared in today’s software tutorial. The shortcut method of sending web pages to the desktop in Edge browser: 1. Open the software and click the "..." button on the page. 2. Select "Install this site as an application" in "Application" from the drop-down menu option. 3. Finally, click it in the pop-up window

What should I do if the images on the webpage cannot be loaded? 6 solutions What should I do if the images on the webpage cannot be loaded? 6 solutions Mar 15, 2024 am 10:30 AM

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! DualBEV: significantly surpassing BEVFormer and BEVDet4D, open the book! Mar 21, 2024 pm 05:21 PM

This paper explores the problem of accurately detecting objects from different viewing angles (such as perspective and bird's-eye view) in autonomous driving, especially how to effectively transform features from perspective (PV) to bird's-eye view (BEV) space. Transformation is implemented via the Visual Transformation (VT) module. Existing methods are broadly divided into two strategies: 2D to 3D and 3D to 2D conversion. 2D-to-3D methods improve dense 2D features by predicting depth probabilities, but the inherent uncertainty of depth predictions, especially in distant regions, may introduce inaccuracies. While 3D to 2D methods usually use 3D queries to sample 2D features and learn the attention weights of the correspondence between 3D and 2D features through a Transformer, which increases the computational and deployment time.

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

How to open php on the web page How to open php on the web page Mar 22, 2024 pm 03:20 PM

Executing PHP code in a web page requires ensuring that the web server supports PHP and is properly configured. PHP can be opened in three ways: * **Server environment:** Place the PHP file in the server root directory and access it through the browser. * **Integrated Development Environment: **Place PHP files in the specified web root directory and access them through the browser. * **Remote Server:** Access PHP files hosted on a remote server via the URL address provided by the server.

Which Linux distribution is best for Android development? Which Linux distribution is best for Android development? Mar 14, 2024 pm 12:30 PM

Android development is a busy and exciting job, and choosing a suitable Linux distribution for development is particularly important. Among the many Linux distributions, which one is most suitable for Android development? This article will explore this issue from several aspects and give specific code examples. First, let’s take a look at several currently popular Linux distributions: Ubuntu, Fedora, Debian, CentOS, etc. They all have their own advantages and characteristics.

See all articles