快速建立Servlet和JSP的运行、调试和编译环境_JSP编程

相信很多刚开始学习Servlet和JSP的朋友都有一个困扰,就是如何快速方便的建立一个Servlet和JSP的运行、调试和编译环境。本人现在正在国外攻读MIT(Master of Information Technology),现在选修的这一科是WBIS(Web Based Information Systems),其包含了许多种技术,如Java,Perl,CGI,Servlet,ASP,Java Script,JSP,OO,UML等等。下面的这篇文章是学校所提供的相关软件的下载地址、安装方法以及相关说明,其中的所需的软件(学校已经给我们提供了CD)我已经全部安装并测试过。这里,我极力推荐给大家,因为整个安装过程非常的简单,只要按照下面文章中的方法一步一步做,100%可以成功,相信会给你带来帮助。虽然文章是全英文的,但很简单,相信大家都能明白。如果有什么问题,希望大家能提出来我们一起讨论。

(注:文章中所提到的四个软件分别是JDK 1.3.1,BlueJ 1.2.0,Apache Tomcat 4.0和bluej_tomcat_config.zip。其中BlueJ是用来创建、编译Servlet的,而最后那个zip文件则是配置BlueJ和Tomcat的。)

BlueJ, Jakarta Tomcat and Java 2 SDK Installation

1. Install the Java 2 Software Development Kit (JDK)

It is recommended that you install JDK 1.3.1, which can be downloaded from here(http://www.csu.edu.au/faculty/sciagr/sis/subjects/itc357/j2sdk-1_3_1-win.exe), or from http://java.sun.com (unfortunately it is a 30M download so if you have a slow modem it may be better to acquire it on CD. For example, there is a CD containing JDK with many Java text books).

Install JDK to the default directory, which is c:\jdk1.3.1

You may use a different version of JDK (1.2 or later) but you will need to change the Tomcat configuration files startup.bat and shutdown.bat to point to the directory location.

2. Install BlueJ (BlueJ is a basic Java editing and compilation environment that sits on top of JDK)

It is recommended that you install BlueJ 1.2.0, which can be downloaded from here(http://www.csu.edu.au/faculty/sciagr/sis/subjects/itc357/bluejsetup-120.exe) or from http://bluej.org

Install BlueJ to the default directory c:\BlueJ

If you install a different version of BlueJ or place it in a different directory the configuration files provided in bluej_tomcat_config.zip will not automatically go into the correct directories and you will have to manually extract each one.

3. Install Apache Tomcat (Tomcat is a Java web application server and will allow you to test your Servlets and JSP files locally)

It is recommended that you install Apache Tomcat 4.0, which can be downloaded from here(http://www.csu.edu.au/faculty/sciagr/sis/subjects/itc357/jakarta-tomcat-4.0.4.exe) or from http://jakarta.apache.org/

Install Tomcat to the default directory c:\Program Files\Apache Tomcat 4.0

If you install a different version of Tomcat or place it in a different directory, you will need to configure it manually as the configuration files provided in bluej_tomcat_config.zip will not automatically go into the correct directories and various paths settings contained in them will not be correct.

4. Configure BlueJ and Tomcat to work together

The recommended way to do this is to download the file bluej_tomcat_config.zip(http://www.csu.edu.au/faculty/sciagr/sis/subjects/itc357/bluej_tomcat_config.zip) and extract the files to the root directory on drive c:, making sure that you choose the option to use folder names.

If you need to manually configure BlueJ or Tomcat, you need to troubleshoot problems or you want to examine the configuration options chosen, they are explained here.

Compiling and Running Servlets on Your Local Machine

1. Run BlueJ and open the existing project in the c:\Program Files\Apache Tomcat 4.0\webapps\testing\Web-inf\classes directory

2. Create a new class and enter the code for your servlet, or use Edit-Add class from file to import an existing servlet source file.

3. Compile the servlet.

4. Start tomcat by double-clicking on startup.bat in the c:\Program Files\Apache Tomcat 4.0\bin directory. This will start Tomcat listening on port 8080 on your local machine (you don't need to be online).

5. Start up your web browser and open the URL http://localhost:8080/testing/servlet/Servletname where Servletname is the name of your servlet.

File locations and relative references within local and remote servlets

HTML files located in a directory like c:\Program Files\Apache Tomcat 4.0\webapps\testing will be accessible through a URL like http://localhost:8080/testing/filename.html

Similarly if you place an HTML file in your home directory on the SWAP server it will be assessible through a URL like http://swap.csu.edu.au:8080/username/filename.html

If you need to place an image in a page generated by a servlet, you can place it in c:\Program Files\Apache Tomcat 4.0\webapps\testing (or on the swap server in your home directory) and refer to it in the HTML as ../imagename.jpg (eg. <IMG SRC="../imagename.jpg">)

If you need to link to another servlet or specify another servlet within the ACTION attribute of a form, you can simply use the servlets name. For example you could use the code <A HREF="OtherServlet"> to link to another servlet assuming that you have a file in the testing\Web-inf\classes directory called OtherServlet.class (or in your Web-inf\classes directory on the SWAP server)

If you have a static HTML page that has a link to a servlet or a form with an ACTION attribute that refers to a servlet, and the HTML page is located in the c:\Program Files\Apache Tomcat 4.0\webapps\testing directory or in your home directory on the SWAP server, use the URL servlet/ServletName to refer to the servlet (eg. ACTION="servlet/ServletName").

It is recommended that you use relative references like these in your HREF, SRC and ACTION attributes so that you can easily move your pages from the local machine to the server.

时间: 2024-10-01 14:38:18

快速建立Servlet和JSP的运行、调试和编译环境_JSP编程的相关文章

快速建立Servlet和JSP的运行、调试和编译环境

js|servlet|编译 相信很多刚开始学习Servlet和JSP的朋友都有一个困扰,就是如何快速方便的建立一个Servlet和JSP的运行.调试和编译环境.本人现在正在国外攻读MIT(Master of Information Technology),现在选修的这一科是WBIS(Web Based Information Systems),其包含了许多种技术,如Java,Perl,CGI,Servlet,ASP,Java Script,JSP,OO,UML等等.下面的这篇文章是学校所提供的相

运行时和编译时元编程—运行时元编程

原文链接   译文链接   译者:JackWang 运行时和编译时元编程 第一部分 Groovy语言支持两种风格的元编程:运行时元编程和编译时元编程.第一种元编程支持在程序运行时修改类模型和程序行为,而第二种发生在编译时.两种元编程有各自的优缺点,在这一章节我们将详细讨论. 注:译者也是第一次接触Groovy,由于时间和水平有限(姑且让译者使用这个理由吧,对待知识本应该一丝不苟)部分专有名词可能翻译不准确甚至有误(读者阅读的过程中最好能参考原文),恳请读者不吝留言指出,谢谢! 1.运行时元编程

运行时和编译时元编程—编译时元编程

原文链接    译文链接     译者:JackWang 运行时和编译时元编程 第二部分 2 编译时元编程 Groovy的编译时元编程支持编译时生成代码.这些变换(译者注:原文该专有名词是transformations,译者直译为变换,也许不准确.如果有知道准确翻译的读者恳请不吝赐教,待译者修正)叫做程序的抽象语法树(AST),在Groovy里,我们叫做AST变换.AST变换支持在编译过程中植入钩子,修改抽象语法树之后继续编译生成正常的字节码流.和运行时元编程相比,这种转换可以在类文件的修改可见

运行时和编译时元编程—运行时元编程(一)

运行时和编译时元编程 第一部分 Groovy语言支持两种风格的元编程:运行时元编程和编译时元编程.第一种元编程支持在程序运行时修改类模型和程序行为,而第二种发生在编译时.两种元编程有各自的优缺点,在这一章节我们将详细讨论. 注:译者也是第一次接触Groovy,由于时间和水平有限(姑且让译者使用这个理由吧,对待知识本应该一丝不苟)部分专有名词可能翻译不准确甚至有误(读者阅读的过程中最好能参考原文),恳请读者不吝留言指出,谢谢! 1.运行时元编程 通过运行时元编程,我们可以推迟运行时的分支决策(译者

JBuilder2005实战JSP之登录页面实现代码[图]_JSP编程

通过File->New...->Web->双击JSP图标,弹出创建JSP向导的对话框,如下图所示: 图 3 通过向导创建login.jsp ·Web module:如果一个工程下有多个Web模块,你可以通过这儿指定JSP所要加入到的Web模块,因为我们的工程中只有一个webModule,所以是向导将默认设置为webModule. ·Name :键入JSP文件名,你可以键入.jsp后缀,也可以不写后缀,直接键入login就可以了. Generate sample bean选项勾选后JBui

困扰JSP的一些问题与解决方法_JSP编程

如今每一个使用servlets的开发者都知道JSP,一种由Sun公司发明并花费大量精力加以推行并建构在servlet技术之上的web技术.JSP将servlet中的html代码脱离了出来,从而可以加速web应用开发和页面维护.实际上,由Sun发布的官方"应用开发模型"文档上说得更远: "JSP技术应该被视为标准,而servlets在多数情况下可视为一种补充." ( Section 1.9, 1999/12/15听取意见版 ). 本文的目的在于听取对该申明的合理性的评

JSP中 Session和作用域的使用_JSP编程

几乎所有的Web开发语言都支持Session功能,Servlet也不例外. Servlet/JSP中的Session功能是通过作用域(scope)这个概念来实现的. 作用域分为四种,分别为: page 在当前页面有效(仅用于JSP中) request 在当前请求中有效 session 在当前会话中有效 application 在所有应用程序中有效 是不是看不太明白?page因为仅用于JSP中,这里只讲述其他三种作用域. 首先要声明的一点,所谓"作用域"就是"信息共享的范围&q

JSP组件commons-fileupload实现文件上传_JSP编程

本文实例为大家分享了JSP使用commons-fileupload实现文件上传代码,供大家参考,具体内容如下 1.准备: 将commons-fileupload-1.1.zip和commons-io-1.1.zip复制到"\WEB-INF\lib"目录下 2.首先是Servlet:FileUpload.java package servlet; import java.io.File; import java.io.IOException; import java.io.PrintWr

运行时和编译时元编程—运行时元编程(二)

1.7.3 ExpandoMetaclass Groovy有一个特殊的MetaClass类叫做ExpandoMetaClass.它的特别之处在于支持动态添加或修改方法,构造函数,属性,甚至通过使用一个闭包语法来添加或修改静态方法. 这些特性测试场景将会非常使用,具体在测试指南将会说明. 在Groovy里,每一个java.lang.Class类都有一个特殊的metaClass属性,可以通过它拿到一个ExpandoMetaCalss实例.这个实例可以被用于添加方法或修改一个已经存在的方法的行为. 默