- 浏览: 1381051 次
- 性别:
- 来自: 江西
文章分类
- 全部博客 (287)
- oracle (30)
- Java (73)
- MySQL (16)
- Myeclipse/eclipse (12)
- javascript (15)
- JSP/Servlet (7)
- maven (14)
- AJAX (2)
- JQuery (9)
- tomcat (8)
- spring (21)
- Linux (28)
- PHP (9)
- UI (1)
- 编程错误及处理 (38)
- 多线程 (18)
- hibernate (10)
- Web Service (3)
- struts2 (6)
- log4j (3)
- SVN (4)
- DWR (1)
- lucene (1)
- 正则表达式 (4)
- jstl (2)
- SSL (3)
- POI (1)
- 网络编程 (1)
- 算法 (2)
- xml (4)
- 加密解密 (1)
- IO (7)
- jetty (2)
- 存储过程 (1)
- SQL Server (1)
- MongoDB (1)
- mybatis (1)
- ETL (1)
- Zookeeper (1)
- Hadoop (5)
- Redis (1)
- spring cloud (1)
最新评论
-
ron.luo:
牛逼,正解!
maven设定项目编码 -
lichaoqun:
java.sql.SQLException: Can't call commit when autocommit=true -
Xujian0000abcd:
Thanks...
Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the clas -
renyuan2ni:
[i][b][u]引用[list]
[*][img][flas ...
Manual close is not allowed over a Spring managed SqlSession -
851228082:
宋建勇 写道851228082 写道<!-- 文件拷贝时 ...
maven设定项目编码
getOutputStream() has already been called for this response
错误信息:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:626)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:205)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:182)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:123)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:80)
at org.apache.jsp.error_jsp._jspService(error_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:581)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:518)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:166)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at com.ipharmacare.plat.interceptor.DeptAndDocInterceptor.intercept(DeptAndDocInterceptor.java:66)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.TrimStringInterceptor.doIntercept(TrimStringInterceptor.java:43)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.RequestTypeInterceptor.intercept(RequestTypeInterceptor.java:27)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.BaseUrlInterceptor.intercept(BaseUrlInterceptor.java:43)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ipharmacare.xiaojdm.filter.DBUpdatingFilter.doFilter(DBUpdatingFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.dj.core.ConFilter.doFilter(ConFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:350)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ipharmacare.xiaojdm.filter.SpringFilter.doFilterInternal(SpringFilter.java:34)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)...
原先代码:
错误原因是不能使用BufferedInputStream作为输出对象,应该用ByteArrayInputStream
修改后的代码如下:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:626)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:205)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:105)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:182)
at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:123)
at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:80)
at org.apache.jsp.error_jsp._jspService(error_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:581)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:518)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:166)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:371)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:275)
at com.ipharmacare.plat.interceptor.DeptAndDocInterceptor.intercept(DeptAndDocInterceptor.java:66)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.TrimStringInterceptor.doIntercept(TrimStringInterceptor.java:43)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.RequestTypeInterceptor.intercept(RequestTypeInterceptor.java:27)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.ipharmacare.plat.interceptor.BaseUrlInterceptor.intercept(BaseUrlInterceptor.java:43)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ipharmacare.xiaojdm.filter.DBUpdatingFilter.doFilter(DBUpdatingFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.dj.core.ConFilter.doFilter(ConFilter.java:34)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:350)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.ipharmacare.xiaojdm.filter.SpringFilter.doFilterInternal(SpringFilter.java:34)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)...
原先代码:
/** * 加载图片 * * @return */ @Action(value = "inputStream", results = { @Result(name = "stream", type = "stream", params = { "contentType", "image/jpeg", "inputName", "inputStream" }) }) public String inputStream() { CustomInstructionImg cii = customInstructionImgService .get(getParameter("id")); byte[] imgFile = cii.getImgFile(); if (null != cii && null != imgFile) { InputStream in = null; try { in = new ByteArrayInputStream(imgFile); inputStream = new BufferedInputStream(in); } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(in); } } return "stream"; } private BufferedInputStream inputStream;省略get/set
错误原因是不能使用BufferedInputStream作为输出对象,应该用ByteArrayInputStream
修改后的代码如下:
/** * 加载图片 * * @return */ @Action(value = "inputStream", results = { @Result(name = "stream", type = "stream", params = { "contentType", "image/jpeg", "inputName", "inputStream" }) }) public String inputStream() { CustomInstructionImg cii = customInstructionImgService .get(getParameter("id")); byte[] imgFile = cii.getImgFile(); if (null != cii && null != imgFile) { try { inputStream = new ByteArrayInputStream(imgFile); } finally { IOUtils.closeQuietly(inputStream); } } return "stream"; } private ByteArrayInputStream inputStream;省略get/set
发表评论
-
ORA-12505, TNS:listener does not currently know of SID given in connect descript
2017-05-11 18:10 1367数据对接时需要连接对方的Oracle数据库,但程序在运行时出错 ... -
Failed to introspect annotations: interface com.xxx
2016-07-16 17:22 3874在使用maven打包发布项目时发现在tomcat容器中正常启动 ... -
MYSQL server has gone away
2016-07-08 20:08 650在使用命令source导入SQL数据时报错如下: 造成此问 ... -
java.io.NotSerializableException: java.util.ArrayList$SubList
2016-03-15 11:36 2867错误信息: 原代码: if (null != dto ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 2053错误信息: java.lang.IllegalStateExc ... -
java.lang.IllegalStateException: Form too large586563>200000
2015-12-16 19:49 24错误信息: java.lang.IllegalStateExc ... -
The function size must be used with a prefix when a default namespace is not
2015-07-30 21:39 4233错误信息: 20:23:34.035 %PARSER_ERRO ... -
java.lang.NoSuchMethodError: org.springframework.expression.spel.SpelParserConfi
2015-07-30 09:41 9988错误信息: [WARNING] FAILED remoting ... -
spring aop未执行问题记录
2015-07-03 11:54 1438在类com.ipharmacare.plat.service. ... -
struts2传递参数时造成的404问题记录
2015-06-29 20:44 1052今天使用form表单提交数据时提示404错误,但当我直接在浏览 ... -
quorum.QuorumCnxManager: Cannot open channel to 2 at election address
2015-04-02 15:38 8354在进行hbase分布式安装时出现了如下信息: quorum.Q ... -
could only be replicated to 0 nodes, instead of 1
2015-03-28 17:51 2616用三台Linux搭建hadoop环 ... -
Does not contain a valid host:port authority: file:///
2015-03-08 15:15 1706Does not contain a valid host:p ... -
java.sql.SQLException: Can't call commit when autocommit=true
2015-01-30 11:22 4505错误信息: 一月 30, 2015 11:10:16 上午 o ... -
org.hibernate.TransactionException: nested transactions not supported
2014-07-25 14:06 10669使用hibernate4.3.5和spring4.0.3进行数 ... -
Shutting down 'proxoolDataSource' pool immediately [Shutdown Hook]
2014-07-19 23:03 1897错误信息如下: 原因是ProxoolDataSource的m ... -
org.apache.ibatis.binding.BindingException: Parameter 'ids' not found. Available
2014-06-13 16:01 1985MyBatis批量操作报错:Parameter 'xxxLis ... -
Manual close is not allowed over a Spring managed SqlSession
2014-05-28 21:34 26675整合spring与MyBatis时出现如下警告: [org.s ... -
log4j无日志输出
2014-05-21 15:31 1439今天在运行测试项目时发现没有日志输出(控制台和文件中都没日志输 ... -
class org.springframework.scheduling.quartz.CronTriggerBean
2014-05-09 08:56 2901提示错误信息:java.lang.IncompatibleCl ...
相关推荐
在Java Web开发中,"getOutputStream() has already been called for this response" 是一个常见的错误,通常出现在使用Servlet或JSP时。这个错误意味着在HTTP响应中,`getOutputStream()`已经被调用,然后尝试再次...
1.在tomcat6.0下jsp出现getOutputStream() has already been called for this response异常的原因和解决方法 在tomcat6.0下jsp中出现此错误一般都是在jsp中使用了输出流(如输出图片验证码,文件下载等),没有...
验证码出现getOutputStream() has already been called for this response错误解决
纠结了半天的 java.lang.IllegalStateException: getOutputStream() has already。这个问题困扰了半天,在网上查阅了大量资料 出这个错误一般就是下面2个.....
解决了getOutputStream() has already been called for this response. 并将产生验证码的逻辑从JSP页面中分离出来,单独写了一个类 便于重用。
"Cannot forward after response has been committed" 是一个在Java Web开发中常见的错误,通常与Servlet、Filter或控制器逻辑有关。这个错误表明服务器已经完成了对HTTP响应的处理,并将其发送到客户端,然后试图...
ServletOutputStream out = response.getOutputStream(); out.write("<html><body>Hello, World!</body></html>".getBytes()); out.flush(); out.close(); ``` 描述中的"InputStream i" 提到了输入流`InputStream`...
本篇将深入探讨`response`设置的实例源码,以及如何在Servlet中应用这些设置。 一、Response对象的基本介绍 `HttpServletResponse`接口是`ServletResponse`接口的子接口,它扩展了通用的响应功能,以适应HTTP协议的...
标题 "java.lang.IllegalStateException: OutputStream already obtain" 涉及到的是Java编程中的一个常见错误,特别是当处理I/O流时。这个异常通常在尝试获取已经存在的OutputStream实例时抛出,表明该输出流已经被...
try (OutputStream out = response.getOutputStream()) { // 使用Apache POI或其他库生成Excel内容并写入out流 } ``` #### 五、动态生成JPEG图像 如果需要动态生成并发送JPEG格式的图像,也需要设置正确的响应...
Returns a boolean indicating whether the named response header has already been set. contextDestroyed(ServletContextEvent) - Method in interface javax.servlet.ServletContextListener Notification ...
OutputStream ou = new BufferedOutputStream(response.getOutputStream()); response.setContentType("application/octet-stream"); // 设置响应类型为二进制流 // 写入响应流并关闭 ou.write(buffer); ou....
2. getOutputStream():从Servlet中可以通过getOutputStream方法取得ServletOutputStream对象,既可以输出字符数据,也可以输出MIME格式的二进制数据。 3. setContentType():在响应中可以表明内容格式和长度。 4. ...
这里使用了Servlet的`HttpServletResponse`对象,调用其`setContentType`方法设置响应的MIME类型为`image/jpeg`或`image/png`,然后使用`getOutputStream`获取输出流,并调用`ImageIO.write`方法将图片写入。...
在Java Web开发中,`response.jsp`通常是指服务器端的响应页面,主要涉及Servlet和JSP(JavaServer Pages)技术。`response`对象是Servlet API中的一个关键组件,全称为`HttpServletResponse`,它用于构建并发送回...
JSP内置对象request和response详解 JSP内置对象request和response是JSP开发中两个非常重要的对象,它们分别用于处理客户端请求和响应信息。在本文档中,我们将详细介绍request和response对象的功能和使用方法。 ...
3. 使用`FileInputStream`读取文件内容,并通过`response.getOutputStream().write()`将内容写入响应流。 通过以上方法,我们可以在处理中文文件名的文件下载时,有效避免乱码问题,确保用户能够正确下载并识别文件...
3. `getOutputStream()`:返回ServletOutputStream,用于写入二进制数据到响应体,如文件下载。 4. `getWriter()`:返回PrintWriter,用于写入文本数据到响应体,如HTML、JSON等。 在实际应用中,我们通常会创建一...