aspose file tools*
The moose likes Struts and the fly likes What's the matter? Struts+SQLServer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "What Watch "What New topic
Author

What's the matter? Struts+SQLServer

carol wind
Greenhorn

Joined: Mar 07, 2013
Posts: 4
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

Joined: Jul 17, 2012
Posts: 94

Make sure you have called close(); method on all variables for which you have used getOutputStream(); in your action class.

Learning some thing New Every Day
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8710
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's the matter? Struts+SQLServer
 
Similar Threads
What's the problem with this?
Error while ajax call on onchange event of select box...struts 1.x?
JSP,JDBC
What's the problem with this?
Rmi in JSF giving connect problem