HttpServletRequest与ServletRequest的区别

05-Servlet-常见的接口和类HttpServlet/HttpServletResponse/HttpServletRequest等 Servlet API定义了一些接口和类,开发者可以通过实现这些接口或继承这些类来编写自己的Servlet。 阅读详情

总结

1.HttpServletRequest和ServletRequest都是接口。
2.HttpServletRequest继承ServletRequest。

以下转载

ServletRequest接口

简述:

在Servlet接口中的service(ServletRequest request , ServletResponse response)方法中有一个ServletRequest类型的参数。ServletRequest类表示来自客户端的请求。当Servlet容器接收到客户端要求访问特定Servlet的请求时,容器先解析客户端的原始请求数据,把它包装成一个ServletRequest对象。当容器调用Servlet对象的service()方法时,就可以把ServletRequest对象呢作为参数传给service()方法。

请求对象方法

ServletRequest接口提供了一系列用于读取客户端请求数据的方法,如下:
1)getContentLength():返回请求正文的长度。如果请求正文的长度位置,则返回-1.
2)getContentType():获得请求正文的MIME类型。如果请求正文的类型未知,则返回null。
3)getInputStram():返回用于读取请求正文的输入流。
4)getLocalAddr():返回服务器短短的IP地址。
5)getLocalName():返回服务器端的主机名。
6)getLocalPort():返回服务器端的FTP端口号。
7)getParameter(String name):根据给定的请求参数名,返回来自客户请求中的匹配的请求参数值。
8) getProtocal():返回客户端和服务器端通信所用的协议的名称及版本号。
9)getReader():返回用户读取字符串形式的请求正文的BufferedReader对象。
10)getRemoteAddr():返回客户端的IP地址。
11)getRemoteHost():返回客户端的主机名。
12)getRemotePort():返回客户端的FTP端口号。
下面三个方法用户在请求范围内存取共享数据的方法:
1)setAttribute(String name , java.lang.Object object):在请求范围内保存一个属性,参数name标识属性名,参数object标识属性值。
2)getAttribute(String name):根据name参数给定的属性名,返回请求范围内的匹配的属性值。
3)removeAttribute(String name):从请求范围内删除一个属性。

HttpServletRequest接口

HttpServletRequest接口是ServletRequest接口的子接口。
HttpServlet类的重载service()方法及doGet()和doPost()等方法都有一个HttpServletRequest类型的参数,如:

protected void service(HttpServletRequest req, HttpServletResponse resp)  
throws ServletException, IOException{........}  

响应方法
HttpServletRequest接口提供了用于读取HTTP请求中的相关信息的方法:
1)getContextPath():返回客户端所请求访问的web应用的URL入口。例如,如果客户端访问的URL为http://localhost:8080/helloapp/info,那么该发放返回“/helloapp”。
2)getCookies():返回HTTP请求中的所有的Cookie。
3)getHeader(String name):返回HTTP请求头部的特定项。
4)getHeaderNames():返回一个Enumeration对象,它包含了HTTP请求头部的所有项目名。
5)getMethod():返回HTTP请求方式,如post,或get。
6)getRequestURI():返回HTTP请求的头部的第1行中的URI。
7)getQueryString():返回HTTP请求中的查询字符串,即UTL中的“?”后面的内容。例如,如果客户端访问的URL为
http://localhost:8080/htlloapp/info?username=tom
,那么该方法返回“username=tome”。
根据SUN的Servlet API来创建的Servlet,无需费力的解析原始HTTP请求。解析原始HTTP请求的工作完全由Servlet容器来代劳。Servlet容器把HTTP请求包装成HttpServletRequest对象,Servlet只需调用该对象的getXXX()方法,节能轻轻松松地读取到HTTP请求中的各种数据。

HttpServletRequest概述、相关方法、获取请求行信息、获取请求头信息相关方法及获取请求参数相关方法 HttpServletRequest概述及相关方法 阅读详情

相关推荐

FPGA实战 —— 基于UART的多设备串口通信系统设计

本文深入探讨了基于FPGA的多设备UART串口通信系统设计。针对工业控制与物联网应用中一对多通信的需求,文章对比了共享总线式、多路独立式等硬件连接方案,并详细阐述了可配置UART IP核、波特率自适应算法以及多路数据仲裁与分发逻辑等核心设计要点。最后,通过一个四传感器采集节点的实战案例,展示了从硬件连接到Verilog代码实现的完整系统构建过程。

weixin_29172963的博客 234

ServletRequest 和 HttpServletRequest 接口详解

ServletRequest接口提供了通用的请求信息的访问方法,而HttpServletRequest接口主要是为了提供更多HTTP特定的请求信息,方便在开发中处理HTTP请求和响应。需要注意的是,在 Tomcat 8 中已解决了 get 方式提交请求中文乱码的问题,使用 Tomcat 8 及以上版本的同学不必再考虑此问题了,如果您使用的是 Tomcat 7 或更早的版本,出现乱码问题可以使用如下的方案解决。因此,URL是URI的一个子集,所有的URL都是URI,但不是所有的URI都是URL。

swadian2008的博客 9681

RK3588 MIPI屏幕调试避坑指南:双通道8Lane下DSC压缩屏的花屏、分层问题排查实录

本文详细解析了RK3588平台在双通道8Lane MIPI接口下调试DSC压缩屏时遇到的花屏、分层问题。通过硬件信号完整性检查、软件配置验证及帧数据分析,提供了一套系统化的排查方法,并深入探讨了初始化序列优化和双通道同步机制,帮助工程师高效解决高分辨率屏幕显示异常问题。

weixin_27015733的博客 282

Servlet技术浅析(三)之-----ServletRequest接口和HttpServletRequest接口

在Servlet接口中的service(ServletRequest request , ServletResponse response)方法中有一个ServletRequest类型的参数。ServletRequest类表示来自客户端的请求。当Servlet容器接收到客户端要求访问特定Servlet的请求时,容器先解析客户端的原始请求数据,把它包装成一个ServletRequest对象。当容器调

红桃峰峰 的博客 7123

FastAPI + Layui:打造企业级敏捷开发后台管理系统

本文详细介绍了如何使用FastAPI和Layui构建高效的企业级后台管理系统。FastAPI提供高性能的异步API支持,而Layui则简化了前端开发流程,两者结合可实现快速开发和部署。文章涵盖了从环境搭建、核心组件开发到性能优化的全流程,特别适合需要敏捷开发的企业项目。

weixin_29045585的博客 555

T2T基因组组装实战指南:从数据到完整染色体

本文详细介绍了T2T基因组组装技术的实战指南,从测序数据选择到完整染色体组装的全流程。重点解析了ONT ultra-long和PacBio HiFi测序技术的优势,以及如何攻克端粒和着丝粒等重复区域的组装难题。通过具体案例和实用技巧,帮助研究人员实现从数据到完整染色体的高质量组装。

weixin_29292535的博客 846

Request、 ServletRequest、HttpServletRequest的区别与联系

1.HttpServletRequest和ServletRequest都是接口,HttpServletRequest继承ServletRequest,只是HttpServletRequest比ServletRequset多了一些http协议的方法,如getHeader()、getMethod()等 2.Request是在jsp中使用的,其实只是规范中的一个名称而已。它是一个对象,但不是有SUN提供的,这是由各个不同的Servlet提供商编写的,SUN只规定了这个类要实现HttpServletR...

weixin_45872600的博客 8353

2025.06.16【转录组】|Ribo-seq数据流程详解(二 基因组比对)

本文详细介绍了Ribo-seq数据分析中的比对流程,包括环境准备、STAR索引构建、比对参数设置及结果统计可视化。通过samtools和R脚本实现比对质量评估,提供常见问题解决方案和关键指标解读。该流程强调比对参数优化和质量控制,为后续翻译组学分析奠定基础。

1980

servletrequest和httpservletrequest两者的区别

请问HttpServletRequest和ServletRequest的区别?  servlet理论上可以处理多种形式的请求响应形式  http只是其中之一  所以HttpServletRequest、 HttpServletResponse分别是ServletRequest和ServletResponse的子类  -------------------------

阶段丶成长的博客 1294

Android 13 SPRD 源码默认打开多用户实际无效果问题修复

【代码】Android 13 SPRD 源码默认打开多用户实际无效果问题修复。

m0_60898338的博客 449

MicroPython学习:在STM32上进行移植

本文将介绍如何在STM32上移植MicroPython,并提供相应的源代码。通过以上步骤,你已经成功地将MicroPython移植到STM32上,并可以使用MicroPython语言编写和运行代码。你可以进一步探索MicroPython的功能和API,以利用STM32的各种外设和功能。使用STM32CubeProgrammer或其他适当的烧录工具,将编译生成的MicroPython固件烧录到STM32微控制器中。打开该文件,并根据你的STM32微控制器类型进行必要的配置更改。模块来控制STM32的LED。

JeeVue的博客 1237

Request 、HttpRequest、Servlet、ServletRequest、HttpServletRequest 的区别

Request(一次请求) 所谓的Request(在JSP中使用的)其实只是规范中的一个名称而已。 它当然是一个对象,但并不是SUN提供的,这是由各个不同的Servlet提供商编写的,SUN只是规定这个类要实现HttpServletRequest接口,并且规定了各个方法的用途,但具体是什么类是由各个提供商自己决定的。 HttpRequest(个人理解:大荒意义上的一个请求,比如人们常说的 ...

Sucker的小笔记 2559

【3D无序抓取】--终极技术详解

3D无序抓取技术详解:从感知到执行的全流程技术方案 本文系统梳理了3D无序抓取(Bin Picking)的核心技术栈,涵盖3D感知、抓取规划和机器人执行三大环节。在3D感知层,详细介绍了点云采集与预处理方法(PCL/Open3D)、物体分割(PointNet++)和位姿估计(PVN3D/DenseFusion)等关键技术。抓取规划部分重点解析了抓取生成(GraspNet)、质量评估(Dex-Net)和动态避障(MoveIt!)算法。机器人执行环节则涉及路径规划、力控技术和末端执行器选型。同时提供了完整的工具

weixin_45590420的博客 598

ServletRequest 和 HttpServletRequest区别

例如filter中的参数就是ServletRequest,而struts的action中execute方法参数是HttpServletRequest HttpServletRequest继承ServletRequest,Servlet里有doGet、doPost方法 ,没有doPut方法,是和form的get post对应的. servletRequest是接口,httpServlet

u010002783的专栏 947

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

HttpServletRequest和ServletRequest的区别

问题:  请问HttpServletRequest和ServletRequest的区别?  回答:  servlet理论上可以处理多种形式的请求响应形式  http只是其中之一  所以HttpServletRequest、 HttpServletResponse分别是ServletRequest和ServletResponse的子类  -------------------------------...

Flyer的后花园 7535

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ServletRequest和HttpServletRequest的联系与区别

HttpServletRequest和ServletRequest都是接口 HttpServletRequest继承自ServletRequest HttpServletRequest比ServletRequest多了一些针对于Http协议的方法。如getHeader (String name), getMethod () ,getSession () 等等。 他

积累与坚持 985

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

ServletRequest 和 HttpServletRequest有什么区别?

filter中的参数就是ServletRequest,而struts的action中execute方法参数是HttpServletRequest HttpServletRequest继承ServletRequest,Servlet里有doGet、doPost方法 ,没有doPut方法,是和form的get post对应的. servletRequest是接口,httpServletRe

David_Tsai23的专栏 1254

HttpServletRequest, ServletRequest, Request的区别

Request: 代表HTTP请求的对象. 在浏览器向服务器发送请求之后, 服务器接受到请求, 在调用service方法处理请求之前, 会创建Request对象, 并把所有的请求信息( 请求行、请求头、请求实体 ) 全部封装到Request对象中. ServletRequest: ServletRequest由Servlet容器来管理,当客户请求到来时,容器创建一个ServletRequ...

qq_22111013的博客 394

ServletRequest、 HttpServletRequest的联系与区别(一)

一、首先,如何理解记忆这几哥老关 servlet理论上可以处理多种形式的请求响应形式,http只是其中之一,servlet范围最大,http开头的是属于他的 所以HttpServletRequest HttpServletResponse分别是ServletRequest和ServletResponse的子类 二、HttpServletRequest介绍 HttpServletRequest对象...

qq_27721753的博客 581
上一篇: activiti之spring管理监听器的方法
下一篇: Windows上本地安装MySQL数据库
十月丶
博客等级 码龄10年 3粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值