Home Database Mysql Tutorial JSP入门教程(1)_MySQL

JSP入门教程(1)_MySQL

Jun 01, 2016 pm 02:08 PM
java jsp web use getting Started Install Tutorial server

 
    JavaServer Pages (JSP)是基于Java的技术,用于创建可支持跨平台及跨Web服务器的动态网页。

JSP可与微软的Active Server Pages (ASP)相媲美,但JSP使用的是类似于HTML的标记和Java 代码片段而不是用VBScript。当你使用不提供ASP本地支持的Web服务器(例如 Apache或Netscape服务器)时,你就可以考虑使用JSP了。你虽然也可以为这些服务器弄一个ASP附加软件模块,但是太昂贵了。现在Sun公司并不会因你使用JSP向你收费(虽然将来可能要收),况且用于Solaris、 Linux以及Windows系统的组件都很容易获得。

不要把JSP与服务器端的JavaScript语言搞混了。Web服务器自动将通过JSP生成的Java代码片段转换成Java 片段(servlets)。 JSP也可自动控制许多功能,如过去用Perl脚本编写功能程序或像ASP这样的服务器专用API(应用编程接口)。

我们马上就要开始帮助你建立一个使用JSP 技术的网站范例了。



准备好计算机以使用JSP

你需要Java2软件开发工具箱(J2SDK),过去称之为Java开发工具箱(JDK)、JavaServer 网络开发工具箱(JSWDK)、Tomcat,或者其它能支持JSP的Web服务器。升阳公司为Windows、Solaris以及 Linux平台提供免费的J2SDK和JSWDK。

如果你想在现有的Web服务器上使用JSP,而此服务器本身不支持JSP和Java 代码片段,可以试用Allaire公司的Jrun。它可以为Netscape的Enterprise Server和Fasttrack Server、微软的Internet Information Server(IIS)和Personal Web Server(PWS)、Apache以及其他服务器充当Web服务器附件。你也可以使用Apache服务器的Java版,其中包含最新的JSWDK。

下载并安装所需的软件
目前,版本号为1.2.2-001的J2SDK可下载版以可安装的归档文件形式出现。这个大约20MB的下载量软件可提供一个彻底的Java开发环境,让你创造任何基于Java并且利用了而标准核心API的解决方案。其实,你的Web服务器使用JSP的唯一条件是要有Java编辑器。要让Web服务器知道编辑器的位置,需要JAVA_HOME 环境变量设置为J2SDK安装目录。如果你已经在Windows系统中进行了安装并且接受了默认目录, 请将“set JAVA_HOME=C:1.2.2”添加到你的“autoexec.bat”文件中,然后重新启动。

安装J2SDK后,下载并安装JSWDK或者是Tomcat β版,即基于Java的Apache Web服务器的β版。你把JSWDK放在什么地方是无关紧要的,只要你以后能找到它就行。通常,将其放在顶层目录中,这样你在替换JSWDK或JSDK时无需删除另一个软件。安装好这个文件后,准备工作已经就绪,你可以开始JSP开发工作了。

正确地安装JSWDK后,请运行“startserver”脚本程序,以启动Web服务器,使其按照默认情况监听8080端口。你要在启动服务器之后查看您是否已正确地安装了此工具,请加载一个JSP样本文件(http://locahost:8080/examples/jsp/)。如果你能成功地运行这些样本文件,说明你已经正确地安装了这个软件。如果你在用来启动服务器的控制台窗口中看到报错信息,你就需要做些修改。最经常发生的问题是没有设置或不正确地设置了JAVA_HOME环境变量。要看到当前环境变量设置情况,要请在DOS提示符下键入“set”设置。

开始
在解释 JSP语法前,创建一个快捷网页,显示目当前的日期和时间,并然后将之其保存为sample.jsp:



First Page


Today is:



.

把这个文件以及你所有的HTML 和 JSP 页面放在JSWDK安装目录下的网页目录里。你可以从http://localhost:8080/sample.jsp加载此网页。该网页首次被访问时,Web服务器会把JSP编译成Java代码片段,这样你就能够看到当前的日期和时间了。
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Square Root in Java Square Root in Java Aug 30, 2024 pm 04:26 PM

Guide to Square Root in Java. Here we discuss how Square Root works in Java with example and its code implementation respectively.

Perfect Number in Java Perfect Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Random Number Generator in Java Random Number Generator in Java Aug 30, 2024 pm 04:27 PM

Guide to Random Number Generator in Java. Here we discuss Functions in Java with examples and two different Generators with ther examples.

Weka in Java Weka in Java Aug 30, 2024 pm 04:28 PM

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Armstrong Number in Java Armstrong Number in Java Aug 30, 2024 pm 04:26 PM

Guide to the Armstrong Number in Java. Here we discuss an introduction to Armstrong's number in java along with some of the code.

Smith Number in Java Smith Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

Java Spring Interview Questions Java Spring Interview Questions Aug 30, 2024 pm 04:29 PM

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

See all articles