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,一经查实,立即删除!

相关文章

计算机应用基础案例实训教程,计算机应用基础案例式实训教程

计算机应用基础案例式实训教程语音编辑锁定讨论上传视频《计算机应用基础案例式实训教程》是2014年3月出版的图书&#xff0c;作者是刘云芳。[1]书 名计算机应用基础案例式实训教程作 者刘云芳出版时间2014年3月页 数311 页定 价42 元开 本16 开装 帧平装ISB…

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

来源&#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的话会报错的…

Openstack(二)基本环境准备--网络、时间、yum源等

2.1服务器版本安装 2.1.1服务器使用&#xff1a;centos7.4 vm12 2.1.2重命名网卡&#xff1a; 传递内核参数 net.ifnames0 biosdevname0&#xff0c;以更改网卡名称为eth0&#xff0c;ethX&#xff1a; #出现安装界面时使用键盘上下键移动到第一行即Install Centos Linux 7&am…

计算机辅助普通话水平测试评分办法,计算机辅助普通话水平测试评分试行办法...

【导读】中公河北邯郸教师招聘考试网提供邯郸中公教育发布的&#xff1a;计算机辅助普通话水平测试评分试行办法&#xff0c;更多教师招聘公告、教师招聘职位表、教师备考资料&#xff0c;可关注邯郸中公教育微信公众号(offcnhd)。一、根据《普通话水平测试大纲》(教语用[2003]…

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;但是却很难…

python求和函数从1到m_python求从M个列表中取N个出来的组合算法

一共有17个列表&#xff0c;要求每次随机抽取6个做组合运算&#xff0c;并将结果输出屏幕。list1["H1","A2","F2","G2","A3","C3","G3","G4","I4","C5","F5",…

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

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

数组/字符串

目录 1768 交替合并字符串 1431 拥有最多糖果的孩子 605 种花问题 345 反转字符串中的元音字母 1768 交替合并字符串 class Solution { public:string mergeAlternately(string word1, string word2) {int n max(word1.size(),word2.size());string res;for(int i 0;i…

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

依据电子科大沙河校区最新收费标准&#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…

oracle 查询表空间路径

select * from dba_data_files转载于:https://www.cnblogs.com/xsdf/p/8629170.html

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

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

python百度翻译接口_python3 调用百度翻译API翻译英文

自行申请百度开发者账号import importlib,sys,urllib importlib.reload(sys) import urllib.request import json #导入json模块 import hashlib import urllib import random def translate(inputFile, outputFile): fin open(inputFile, r,encodingutf-8) #以读的方式打开输…

BZOJ2150: 部落战争

【传送门&#xff1a;BZOJ2150】 简要题意&#xff1a; 给出一个矩阵&#xff0c;矩阵上的字符有两种&#xff0c;一种是x&#xff0c;表示山洞&#xff08;不可走&#xff09;&#xff0c;一种是.&#xff0c;表示城镇 可以在城镇处放士兵&#xff0c;士兵经过的每个城镇都会被…