分享
 
 
 

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

王朝java/jsp·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

相信很多刚开始学习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.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有