当前位置:  编程技术>java/j2ee

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

    来源: 互联网  发布时间:2014-10-14

    本文导语:  相信很多刚开始学习Servlet和JSP的朋友都有一个困扰,就是如何快速方便的建立一个Servlet和JSP的运行、调试和编译环境。本人现在正在国外攻读MIT(Master of Information Technology),现在选修的这一科是WBIS(Web Based Information Systems)...

相信很多刚开始学习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 FilesApache 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 FilesApache Tomcat 4.0webappstestingWeb-infclasses 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 FilesApache Tomcat 4.0bin 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 FilesApache Tomcat 4.0webappstesting 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 FilesApache Tomcat 4.0webappstesting (or on the swap server in your home directory) and refer to it in the HTML as ../imagename.jpg (eg. )







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 to link to another servlet assuming that you have a file in the testingWeb-infclasses directory called OtherServlet.class (or in your Web-infclasses 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 FilesApache Tomcat 4.0webappstesting directory or in your home directory on the SWAP server, use the URL servlet/ServletName to refer to the servlet (eg. ACTION="/tech-java/servlet/ServletName/index.html").







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.

    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • linux下怎么建立自己的程序文件并运行
  • 请教:运行时候建立控件的问题
  • 自己写的批量建立用户的shell无法运行~~~~~
  • 用pthread_create建立线程后如何让线程运行的函数在create完了之后才实际运行 相当与windows下的CREATE_SUSPENDED ??
  • 谢谢!请问如何建立JAVA小程序运行环境??
  • 考试题目求解答:如何建立SHELL脚本,运行时挂载WIN的C盘?
  • 安装QT4后建立工程运行qmake-project提示qmake:command not find
  • Redhat/Centos下rpmbuild命令从spec文件或者tar包建立rpm
  • 如何在Red Hat上建立FTP服务 并且建立FTP一个用户
  • 怎样在linux下建立一个PPP服务器,并在另一台机子上通过pppd来建立连接呀?
  • 怎么建立.alias文件?在哪里建立这个文件?
  • 用windows客户机登陆Linux服务器不能建立建立文件夹????[img=http://forum.csdn.net/PointForum/ui/scrip
  • 请问在linux中怎么来建立ftp和web服务器,怎么建立和windows的局域网
  • 很多服务都吧监听同时建立在特定ip和广播ip上,但是使用ssh转发时,发现没法建转发建立在广播ip上
  • 只给一个目录路径,怎样再在其下建立一个新的目录(给定目录名),然后再在其下建立一个新的文件(给定文件名)?
  • unix下获得文件的建立时间
  • linux系统中建立一个用户专门用来修改系统时间怎么做?
  • 哪个DOS命令可以建立一个空文件?
  • 开发板上建立一个nfs服务器
  • 用户ID的建立
  • 建立用户的问题
  • 服务器8G内存,怎样建立swap分区?
  • 如何建立虚拟主机
  • 怎么样在 dos 系统下 批量的建立目录?
  • 请问如何建立“目录的快捷”档?
  • 如何建立批处理?
  • 新手:unix下建立文件的命令?
  • 在pxa255建立linux2.4的系统,需要哪些补丁啊?


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3