File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

What's the matter? Struts+SQLServer

carol wind

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
at org.apache.catalina.connector.ResponseFacade.getWr iter(
at org.apache.jasper.runtime.JspWriterImpl.initOut(Js
at org.apache.jasper.runtime.JspWriterImpl.flushBuffe r(
at org.apache.jasper.runtime.PageContextImpl.release(
at org.apache.jasper.runtime.JspFactoryImpl.internalR eleasePageContext(
at org.apache.jasper.runtime.JspFactoryImpl.releasePa geContext(
at org.apache.jsp.yanzhengma_jsp._jspService(yanzheng
at org.apache.jasper.runtime.HttpJspBase.service(Http
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at org.apache.jasper.servlet.JspServletWrapper.servic e(
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(
at org.apache.jasper.servlet.JspServlet.service(JspSe
at javax.servlet.http.HttpServlet.service(HttpServlet .java:728)
at ternalDoFilter(
at Filter(
at org.apache.struts2.dispatcher.ActionContextCleanUp .doFilter(
at ternalDoFilter(
at Filter(
at org.apache.struts2.dispatcher.FilterDispatcher.doF ilter(
at ternalDoFilter(
at Filter(
at org.apache.catalina.core.StandardWrapperValve.invo ke(
at org.apache.catalina.core.StandardContextValve.invo ke(
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke (
at org.apache.catalina.valves.AccessLogValve.invoke(A
at org.apache.catalina.core.StandardEngineValve.invok e(
at org.apache.catalina.connector.CoyoteAdapter.servic e(
at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(
at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ (Unknown Source)
at 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"
maxActive="100" maxIdle="30" maxWait="10000"
username="admin" password="123456"
driverClassName=" erverDriver"

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

Joined: Oct 29, 2001
Posts: 9189

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.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: What's the matter? Struts+SQLServer
It's not a secret anymore!