servlet源码查看

1,下载源码,点击此处可下载

2,创建web项目

我这里以jdbc这个web项目为例讲解

在javaee libraries中有个javaee.jar包,选中它-->右击--》Properties

 找到你下载的jar包

打开---apply  即可】

在任意一个.java文件中,编写servlet,按住ctrl键,鼠标单击类(或接口)名,即可查看源码

下面是servlet完整源码

/** DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.** Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.** The contents of this file are subject to the terms of either the GNU* General Public License Version 2 only ("GPL") or the Common Development* and Distribution License("CDDL") (collectively, the "License").  You* may not use this file except in compliance with the License.  You can* obtain a copy of the License at* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html* or packager/legal/LICENSE.txt.  See the License for the specific* language governing permissions and limitations under the License.** When distributing the software, include this License Header Notice in each* file and include the License file at packager/legal/LICENSE.txt.** GPL Classpath Exception:* Oracle designates this particular file as subject to the "Classpath"* exception as provided by Oracle in the GPL Version 2 section of the License* file that accompanied this code.** Modifications:* If applicable, add the following below the License Header, with the fields* enclosed by brackets [] replaced by your own identifying information:* "Portions Copyright [year] [name of copyright owner]"** Contributor(s):* If you wish your version of this file to be governed by only the CDDL or* only the GPL Version 2, indicate your decision by adding "[Contributor]* elects to include this software in this distribution under the [CDDL or GPL* Version 2] license."  If you don't indicate a single choice of license, a* recipient has the option to distribute your version of this file under* either the CDDL, the GPL Version 2 or to extend the choice of license to* its licensees as provided above.  However, if you add GPL Version 2 code* and therefore, elected the GPL Version 2 license, then the option applies* only if the new code is made subject to such option by the copyright* holder.*** This file incorporates work covered by the following copyright and* permission notice:** Copyright 2004 The Apache Software Foundation** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package javax.servlet;import java.io.IOException;/*** Defines methods that all servlets must implement.** <p>A servlet is a small Java program that runs within a Web server.* Servlets receive and respond to requests from Web clients,* usually across HTTP, the HyperText Transfer Protocol. ** <p>To implement this interface, you can write a generic servlet* that extends* <code>javax.servlet.GenericServlet</code> or an HTTP servlet that* extends <code>javax.servlet.http.HttpServlet</code>.** <p>This interface defines methods to initialize a servlet,* to service requests, and to remove a servlet from the server.* These are known as life-cycle methods and are called in the* following sequence:* <ol>* <li>The servlet is constructed, then initialized with the <code>init</code> method.* <li>Any calls from clients to the <code>service</code> method are handled.* <li>The servlet is taken out of service, then destroyed with the * <code>destroy</code> method, then garbage collected and finalized.* </ol>** <p>In addition to the life-cycle methods, this interface* provides the <code>getServletConfig</code> method, which the servlet * can use to get any startup information, and the <code>getServletInfo</code>* method, which allows the servlet to return basic information about itself,* such as author, version, and copyright.** @author     Various** @see     GenericServlet* @see     javax.servlet.http.HttpServlet**/public interface Servlet {/*** Called by the servlet container to indicate to a servlet that the * servlet is being placed into service.** <p>The servlet container calls the <code>init</code>* method exactly once after instantiating the servlet.* The <code>init</code> method must complete successfully* before the servlet can receive any requests.** <p>The servlet container cannot place the servlet into service* if the <code>init</code> method* <ol>* <li>Throws a <code>ServletException</code>* <li>Does not return within a time period defined by the Web server* </ol>*** @param config            a <code>ServletConfig</code> object *                    containing the servlet's*                     configuration and initialization parameters** @exception ServletException     if an exception has occurred that*                    interferes with the servlet's normal*                    operation** @see                 UnavailableException* @see                 #getServletConfig**/public void init(ServletConfig config) throws ServletException;/**** Returns a {@link ServletConfig} object, which contains* initialization and startup parameters for this servlet.* The <code>ServletConfig</code> object returned is the one * passed to the <code>init</code> method. ** <p>Implementations of this interface are responsible for storing the * <code>ServletConfig</code> object so that this * method can return it. The {@link GenericServlet}* class, which implements this interface, already does this.** @return        the <code>ServletConfig</code> object*            that initializes this servlet** @see         #init**/public ServletConfig getServletConfig();/*** Called by the servlet container to allow the servlet to respond to * a request.** <p>This method is only called after the servlet's <code>init()</code>* method has completed successfully.* * <p>  The status code of the response always should be set for a servlet * that throws or sends an error.** * <p>Servlets typically run inside multithreaded servlet containers* that can handle multiple requests concurrently. Developers must * be aware to synchronize access to any shared resources such as files,* network connections, and as well as the servlet's class and instance * variables. * More information on multithreaded programming in Java is available in * <a href="http://java.sun.com/Series/Tutorial/java/threads/multithreaded.html">* the Java tutorial on multi-threaded programming</a>.*** @param req     the <code>ServletRequest</code> object that contains*            the client's request** @param res     the <code>ServletResponse</code> object that contains*            the servlet's response** @exception ServletException     if an exception occurs that interferes*                    with the servlet's normal operation ** @exception IOException         if an input or output exception occurs**/public void service(ServletRequest req, ServletResponse res)throws ServletException, IOException;/*** Returns information about the servlet, such* as author, version, and copyright.* * <p>The string that this method returns should* be plain text and not markup of any kind (such as HTML, XML,* etc.).** @return         a <code>String</code> containing servlet information**/public String getServletInfo();/**** Called by the servlet container to indicate to a servlet that the* servlet is being taken out of service.  This method is* only called once all threads within the servlet's* <code>service</code> method have exited or after a timeout* period has passed. After the servlet container calls this * method, it will not call the <code>service</code> method again* on this servlet.** <p>This method gives the servlet an opportunity * to clean up any resources that are being held (for example, memory,* file handles, threads) and make sure that any persistent state is* synchronized with the servlet's current state in memory.**/public void destroy();
}

 

转载于:https://www.cnblogs.com/excellencesy/p/8623608.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/486592.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

自动驾驶出行,进入下半场

来源&#xff1a;脑极体近两年&#xff0c;出行领域最值得人们期待的创新恐怕就是自动驾驶技术了。经过长达十年的技术积累和两年的商业试验&#xff0c;自动驾驶出行已经正在开放商用的道路上逐渐加速。就在这个月初&#xff0c;百度Apollo自动驾驶出租车在北京海淀、亦庄等区…

python安装百度aip_Python3.6安装aip

AIP的安装&#xff08;此aip非百度AIP&#xff09; 如同以往安装库的方法一样&#xff0c;进入目录&#xff1a;C:\Users\admin\AppData\Local\Programs\Python\Python36\Scripts 执行&#xff1a;pip install aip我们的aip目录如下&#xff1a;如果正常导入AipOcr的话会报错的…

python缩进格式错误的是_Python 中常见错误总结

IndentationError: unexpected indent Python 中强制缩进&#xff0c;&#xff0c; IndentationError: unexpected indent 缩进错误 这类错误非常常见&#xff0c;一般都是由于tab在不同的平台上占用长度不同导致&#xff0c;有些事程序员自己直接使用空格或其他来顶替tab。 解…

史上曾被认为不可能的十大科学难题全被实现

来源&#xff1a;科学解码对于科学家来说&#xff0c;好像没有什么事情是不可能做到的。纵观科学发展史&#xff0c;我们便会发现&#xff0c;一个又一个看似“不可能的任务”最终都成为可能&#xff0c;例如利用核能、上演太空飞行、创建力场以及远距离传物。几个世纪前&#…

广东省一本计算机学校排名,南方科技大学排名2021 广东排名第16全国排名第276...

南方科技大学排名2019 广东排名第16全国排名第276每年的大学排名位次争议很大&#xff0c;虽然各大学校长口头上称不在乎、不看重&#xff0c;但实际上却卯足干劲&#xff0c;希望学校排名靠前&#xff0c;因为大学排名一定程度上体现了高校的办学成就。高考升学网本文介绍的主…

webpack轻松入门教程

webpack之傻瓜式教程及前端自动化入门 接触webpack也有挺长一段时间了&#xff0c;公司的项目也是一直用着webpack在打包处理&#xff0c;但前几天在教新人的情况下&#xff0c;遇到了一个问题&#xff0c;那就是&#xff1a;尽管网上的webpack教程满天飞&#xff0c;但是却很难…

首个单设备模拟神经元出现 可有效解决传统计算机所面临的问题

来源&#xff1a;IEEE电气电子工程师Photo: Research Group of R. Stanley Williams对于工程师们来说&#xff0c;无法实现人类大脑效率和超强计算性能的其中一个原因在于&#xff0c;一直以来我们缺少一种可以独立发挥神经元作用的电子设备。要做到这一一点&#xff0c;需要我…

电子科大沙河校区有计算机专业,电子科大沙河校区学费

依据电子科大沙河校区最新收费标准&#xff0c;电子科大沙河校区的学费每人每年需要4400元-60000元不等。其中中外合作办学项目每人每年需要60000元&#xff1b;理科专业每人每年需要4900元&#xff1b;文科专业每人每年需要4400元&#xff1b;软件工程专业每人每年需要9800元。…

SMB服务简介

1、Samba简介 Samba是种自由软件&#xff0c;用来让UNIX系列的操作系统与微软Windows操作系统的SMB/CIFS(Server Message Block/Common Internet File System)网络协定做连结。在目前的版本(v3)&#xff0c;不仅可存取及分享SMB的资料夹及打印机&#xff0c;本身还可以整合入Wi…

学云计算能干什么_陌陌主播等级计算?陌陌主播升级明细表?

有很多主播对陌陌直播规则都不太清楚&#xff0c;比如就有人问&#xff0c;陌陌主播等级计算&#xff1f;陌陌主播升级明细表&#xff1f;今天跟大家简单的说一下&#xff0c;一起来看看吧。加入海星公会&#xff0c;扶持奖励全都有&#xff0c;主播可获得热门推荐&#xff0c;…

建造自己的「天空之城」,密歇根大学博士后的这项研究可以虚空造物、偷天换日...

来源&#xff1a;机器之心 哈尔的移动城堡&#xff1f;天空之城&#xff1f;这幅图是否让你想起了这两部电影中的场景……上&#xff1a;《天空之城》剧照&#xff1b;下&#xff1a;《哈尔的移动城堡》剧照。是电影场景变为现实了吗&#xff1f;真的有人建造了一座空中楼阁&am…

个人计算机有控制器和运算器吗,cpu是由控制器和运算器组成的对还是错

对的。CPU即中央处理器&#xff0c;是计算机中负责读取指令&#xff0c;对指令译码并执行指令的核心部件。中央处理器主要包括两个部分&#xff0c;即控制器、运算器&#xff0c;其中还包括高速缓冲存储器及实现它们之间联系的数据、控制的总线。一、控制器是整个计算机系统的指…

又一壮举!GPT-3首次完成剧本创作,AI解决创造性问题的能力正迅速提升

来源&#xff1a;中国智慧城市导刊文章原载于 学术头条自今年 6 月份发布以来&#xff0c;OpenAI 的文本生成人工智能工具 GPT-3 获得了极大的关注。它被用来在论坛上发表评论、写诗、甚至在《卫报》中发表文章。当 GPT-3 没有经过专门培训就学会自动完成某项任务时&#xff0c…

Hinton构思下一代神经网络:属于无监督对比学习

本文由机器之心报道Geoffrey Hinton 是谷歌副总裁、工程研究员&#xff0c;也是 Vector Institute 的首席科学顾问、多伦多大学 Emeritus 荣誉教授。2018 年&#xff0c;他与 Yoshua Bengio、Yann LeCun 因对深度学习领域做出的巨大贡献而共同获得图灵奖。自 20 世纪 80 年代开…

windows 获取命令执行后的结果_法院判决以后,老赖欠钱不还,递交强制执行申请多久后有结果?...

网友提问&#xff1a;老赖欠钱不还&#xff0c;已向法院递交了强制执行申请一个月了&#xff0c;老赖仍逍遥法外&#xff0c;该怎么办&#xff1f;这个阶段你称之为老赖&#xff0c;也无不可。但还不是法律上所认可的老赖&#xff0c;法律上的老赖也只是个俗称&#xff0c;学名…

研究揭示动物社交欲望的神经机制

来源&#xff1a;中国科学院生物物理研究所10月22日&#xff0c;中国科学院生物物理研究所朱岩课题组在Nature Communications上发表题为Social attraction in Drosophila is regulated by the mushroom body and serotonergic system的研究论文&#xff0c;研究以果蝇为模型&a…

bat复制文件到指定目录同名_scp复制文件时排除指定文件

请关注本头条号&#xff0c;每天坚持更新原创干货技术文章。如需学习视频&#xff0c;请在微信搜索公众号“智传网优”直接开始自助视频学习1. 前言本文主要讲解如何在scp复制文件时排除指定文件。举例&#xff1a;我需要将所有*.c文件从名为hostA的电脑复制到hostB&#xff0c…

传感器的“脖子”卡在哪儿?

来源&#xff1a;人民政协报昨天胜利闭幕的十九届五中全会研究关于制定“十四五”规划和2035年远景目标的建议。其中加强自主创新、对卡脖子关键技术攻关是重中之重&#xff0c;并将传感器作为“卡脖子”技术攻克目标之一。与此同时美国近期也公布了《关键与新兴技术国家战略》…

服务器大线程有什么作用,全面剖析超线程技术优点与缺点

欢迎各位阅读本篇文章&#xff0c;超线程技术就是利用特殊的硬件指令&#xff0c;把两个逻辑内核模拟成两个物理芯片&#xff0c;让单个处理器都能使用线程级并行计算&#xff0c;进而兼容多线程操作系统和软件&#xff0c;减少了CPU的闲置时间&#xff0c;提高的CPU的运行效率…

遍历矩阵每一行穷举_[LeetCode] 566. 重塑矩阵

题目链接&#xff1a; https://leetcode-cn.com/problems/reshape-the-matrix难度&#xff1a;简单通过率&#xff1a;61.6%题目描述:在MATLAB中&#xff0c;有一个非常有用的函数 reshape&#xff0c;它可以将一个矩阵重塑为另一个大小不同的新矩阵&#xff0c;但保留其原始数…