• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the matter? Struts+SQLServer

 
carol wind
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet.service() for servlet [jsp] in context with path [/rsglxt] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(R esponse.java:639)
at org.apache.catalina.connector.ResponseFacade.getWr iter(ResponseFacade.java:214)
at org.apache.jasper.runtime.JspWriterImpl.initOut(Js pWriterImpl.java:125)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffe r(JspWriterImpl.java:118)
at org.apache.jasper.runtime.PageContextImpl.release( PageContextImpl.java:190)
at org.apache.jasper.runtime.JspFactoryImpl.internalR eleasePageContext(JspFactoryImpl.java:126)
at org.apache.jasper.runtime.JspFactoryImpl.releasePa geContext(JspFactoryImpl.java:80)
at org.apache.jsp.yanzhengma_jsp._jspService(yanzheng ma_jsp.java:138)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.struts2.dispatcher.ActionContextCleanUp .doFilter(ActionContextCleanUp.java:99)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.struts2.dispatcher.FilterDispatcher.doF ilter(FilterDispatcher.java:413)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)

My server.xml:

<Context path="/rsglxt" docBase="D:\Users\wind\workspace\rsglxt"
debug="5" reloadable="true" crossContext="true" workDir="D:\Users\wind\workspace\rsglxt\work">
<Resource name="jdbc/rsglxt"
auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="admin" password="123456"
driverClassName="com.microsoft.sqlserver.jdbc.SQLS erverDriver"
url="jdbc:sqlserver://localhost:1433;DatabaseName=tempdb"/>
</Context>

I have tested connect sqlserver successfully by odbc data source. But I log in from homepage of my java programe, it shows this error.
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you have called close(); method on all variables for which you have used getOutputStream(); in your action class.
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet.service() for servlet [jsp] in context with path [/rsglxt] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause


This exception is usually triggered by one of two things:
-when you are writing data directly to the output stream in your action, close the stream then Struts forwards to a JSP that needs the output stream
-you attempt to use two forwards in your action. The first forward will close the stream and the second will throw an exception.
This probably doesn't have anything to do with SQLServer, but your first step when debugging should be to eliminate possible variables to isolate the problem. Read our FAQ, HowToAskQuestionsOnJavaRanch, try to narrow down the cause and show us some code.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic