欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    The Tomcat Servlet Container.ppt

    • 资源ID:373115       资源大小:411KB        全文页数:28页
    • 资源格式: PPT        下载积分:2000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要2000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    The Tomcat Servlet Container.ppt

    1、The Tomcat Servlet Container,About Tomcat,A “servlet container” is like a mini server, but only for serving html, jsp and servlets. Many servlet containers could be used for this course. Some may even be easier to configure than tomcat, but tomcat provides an easy-to-use development/deployment tool

    2、and also complies with the servlet specification best of all containers. Tomcat is from Apache and is open-source. Tomcat can be used as a stand-alone servlet container. You can install the Apache server with Tomcat, and then proceed to configure each for their individual purposes. (The server would

    3、 relay servlet requests to Tomcat.),About these notes,Two texts & many of my own examples were used to compile servlet notes. The texts referenced are Jason Hunters Servlet book and Core Servlets Vol 1 by Hall & Brown. Both excellent books.,Asides: XML,XML stands for eXtensible-markup-language and i

    4、s a SGML. Unlike older HTML, XML can be validated. XHTML, for example, is HTML that is XML compliant. XML is widely used in internet programming. Some technologies - like SOAP - are based on XML. Many files on Tomcat are XML. In the past Ive taught XML as a full component of this course. I am not do

    5、ing that this semester. There are websites with tutorials. I have links to a whole text of xml content at http:/employees.oneonta.edu/higgindm/internet%20programming/xmllinks.html,More Asides,Case sensitivity Java, C, C+ and Ruby are all case-sensitive languages. At times my notes and ppts will be s

    6、loppy and incorrectly show case, but in your work you cant be sloppy. JAR files, classpath, batch files, environment variables, even WAR files: We are likely to use all of these.,Download tomcat at http:/tomcat.apache.org/,Apache recommends downloading the newest version, although the core servlets

    7、text was written with Tomcat 5.Download the appropriate zip and extract the files to a directory named, for example, jakarta-tomcat-5.0.28 (or whatever the version is) The Core Servlets text maintains a site with tips for configuring different versions of Tomcat at http:/. This site has a preconfigu

    8、red version of Tomcat which I used.,Servlets API,Links to servlet API are on the texts web site You should bookmark the servlet API for reference purposes: http:/tomcat.apache.org/tomcat-5.5-doc/servletapi/ The servlet class files also need to be on your classpath. These are part of java EE but not

    9、part of java SE. I downloaded them and put mine in a c:servlets directory. You may instead include the jar file “copy” from the servers library on your classpath. This would be something like C:tomcatdircommonlibservlet.jar,Classpaths & Environment variables,Classpaths are where the java compiler lo

    10、oks to find classes needed to perform compilation. On your machine, to successfully compile java servlets, packages, and so on, you will have to create an autoexec file to set classpaths, use a special batch file for compilation, or edit the classpath environment variables. The classpath setting may

    11、 need editing whenever you create a package with new classes in it, but should be ok otherwise. Text site has some suggestions of what it should look like. Mine is: C:javasdkjdkbin;c:myclasses;.;C:apache-tomcat-6.0.10libservlet-api.jar;C:apache-tomcat-6.0.10libjsp-api.jar;C:apache-tomcat-6.0.10libel

    12、-api.jar Add ;newdir to the end of this when you add a new classpath. You may need to define environment variable CATALINA_HOME. Got to control panel and select system, then select advanced and then environment variables. Select new (or edit) and add these (one at a time) along with their paths. For

    13、 CATALINA_HOME, point to the jakarta-tomcat-v# directory. For JAVA_HOME point to the jdk directory,Servlets+JSP,This directory came in a pre-configured tomcat version on the Core Servlets books site which I installed. It unzipped into the tomcat directory but I moved it up to c:,Test tomcat installa

    14、tion,Startup tomcat (click the bat file in tomcat/bin) and open http:/localhost in a browser window. Some tomcat stuff should display. If you dont see this there could be many reasons. Probably Tomcat is not configured properly, but you might try http:/localhost:8080 because some versions of Tomcat

    15、are preconfigured to listen at port 8080. (This feature can be modified by editing the conf/server.xml file.) Shutdown tomcat by clicking the shutdown.bat file. (If your installation has a control panel then use the startup/shutdown buttons provided). BTW: youll need to shutdown/startup to get tomca

    16、t to recognize an edited/recompiled classfile unless you edit the server.xml file and add to the Service element of this file.,Testing it,Download or copy the helloservlet.java (It is in the servlets+jsp directory also.) Compile it. Getting the compile to work will reveal problems with your classpat

    17、h settings. Drop the class file into c:/your-tomcat-dir/webapps/ROOT/WEB-INF/classes directory,HelloServlet.java note imports,import java.io.*; import javax.servlet.*; import javax.servlet.http.*;public class HelloServlet extends HttpServlet public void doGet(HttpServletRequest request,HttpServletRe

    18、sponse response)throws ServletException, IOException response.setContentType(“text/html“);PrintWriter out = response.getWriter();String docType =“n“;out.println(docType +“n“ +“Hellon“ +“n“ +“Hello from Higgins in the world of servletsn“ +“); ,Test the hello servlet. You may edit it first,HelloServle

    19、t2.java: a servlet in a package to test,package coreservlets; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloServlet2 extends HttpServlet public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException response.

    20、setContentType(“text/html“);PrintWriter out = response.getWriter();String docType =“n“;out.println(docType +“n“ +“Hello (2)n“ +“n“ +“Hello (2)n“ +“); ,Hello2,A servlet using a package of utilities to test: HelloServlet3.java minus imports,public class HelloServlet3 extends HttpServlet public void do

    21、Get(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException response.setContentType(“text/html“);PrintWriter out = response.getWriter();String title = “Hello (3)“;out.println(ServletUtilities.headWithTitle(title) + “n“ +“ + title + “n“ +“); ,Hello3 servlet uses a

    22、 utility class in the same package,Apache Tomcat Native Library,You may get an error that the APR is missing. Tomcat will run ok without it. To eliminate this warning, you need to get a dll file for the appropriate tomcat version (mine wanted tcnative.dll v1.8) and put it into C:/your-tomcat/bin and

    23、 make sure this dir is on the path settings to get rid of the error. More suggestions are at: http:/tomcat.apache.org/native-doc/,Remarks on Tomcat5.5,Does not require editing classpath or definition of JAVA_HOME or CATALINA_HOME Has windows installer download Has GUI interface for startup/shutdown,

    24、tomcat5w,The new version of tomcat (5.5) seems to install itself ok and comes with a GUI for configuration, startup and shutdown,ROOT,Under the jakarta directory is jakarta-tomcat-v.?.? And under that is webapps. In this directory appears ROOT. The servlets deployed in ROOT are recognized by the ser

    25、ver without further path information. I will often deploy my servlets elsewhere.,Servlet directory structures,In the webapps directory of jakarta/tomcat create a directory for your work, lets say you call it MyStuff Create 2 directories, servlets and web-inf under MyStuff. In servlets, you will put

    26、all your servlet.html files. In web-inf you will place web.xml (your servlet information file) and a directory called classes, where youll place the servlet.class files.,Directory Structure,web.xml,Ive given you a model of your web.xml showing how to place servlet information in the xml file, and al

    27、so how to “grow” the file as you complete more servlets.,web.xml,Java How to Program JSP and Servlet Chapter ExamplesThis is the Web application in which we demonstrate our JSP and Servlet examples.,web.xml- cont,welcome1A simple servlet that handles an HTTP get request.WelcomeServletwelcome2,web.xm

    28、l- cont,A simple servlet that handles an HTTP get request with data.WelcomeServlet2welcome1/welcome1welcome2/welcome2 ,Tomcat,Youll have to watch the blackscreen associated with your server session for errors on startup or reloads. If these occur you may have to fix them before your servlets can be accessed.,


    注意事项

    本文(The Tomcat Servlet Container.ppt)为本站会员(inwarn120)主动上传,麦多课文档分享仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文档分享(点击联系客服),我们立即给予删除!




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1 

    收起
    展开