Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot create a session after the response has been committed (Tomcat 6)

843840Sep 6 2007 — edited Jun 18 2008
I'm getting a rather annoying error when I try to open a pretty basic JSP page.
I'm rather new to the whole JSP scene, so I'm following the example found on pages 287 and onwards in "JSF in Action - Manning" in case anyone wanted to check my code against the source.

I've searched for about 4 hours now, coming back to this site a couple of times, once reading about writeouts and stuff. But I'm not really sure this is the issue in this case and if it is, where exactly the problem lies.
I've already fixed a number of errors I got (jtsl.jar and standard.jar missing etc...) but this particular problem is driving me (and my co-workers for that matter :-) ) up the wall.

Anyone willing to help me out here?

Error:
description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Cannot create a session after the response has been committed
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:152)


root cause 

java.lang.IllegalStateException: Cannot create a session after the response has been committed
	org.apache.catalina.connector.Request.doGetSession(Request.java:2301)
	org.apache.catalina.connector.Request.getSession(Request.java:2075)
	org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
	org.apache.myfaces.context.servlet.SessionMap.setAttribute(SessionMap.java:53)
	org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:103)
	org.apache.myfaces.util.AbstractAttributeMap.put(AbstractAttributeMap.java:35)
	org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedViewInServletSession(JspStateManagerImpl.java:523)
	org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:358)
	javax.faces.application.StateManager.saveView(StateManager.java:47)
	org.apache.myfaces.application.jsp.JspViewHandlerImpl$StateMarkerAwareWriter.flushToWriter(JspViewHandlerImpl.java:387)
	org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:322)
	org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
Source Code of login.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

<f:view>
<html>
<head>
	<title>
		<h:outputText value="ProjectTrack"/>
	</title>
</head>
	<body>
		<table>
			<tr>
				<td>
					<h:graphicImage url="/images/logo Skillteam.jpg"
					alt="Welcome to ProjectTrack"
					title="Welcome to ProjectTrack"
					width="435" height="120"/>
				</td>
			<td>
				<font face="Arial, sans-serif"
				size="6">
				<h:outputText value="ProjectTrack"/>
				</font>
			</td>
			</tr>
	http://forum.java.sun.com/post!default.jspa?forumID=45#
Click for bold	</table>
	</body>
</html>
</f:view>
web.xml & faces-config
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
	<display-name>ProjectTrack</display-name>
	
	<welcome-file-list>
	<welcome-file>faces/login.jsp</welcome-file>
	<welcome-file>index.html</welcome-file>
	</welcome-file-list>
	
	<servlet>
	<servlet-name>Faces Servlet</servlet-name>
	<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
	<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
	<servlet-name>Faces Servlet</servlet-name>
	<url-pattern>/faces/*</url-pattern>
	</servlet-mapping>
	
	
</web-app>


<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
	<navigation-rule>
		<from-view-id>/login.jsp</from-view-id>
		<navigation-case>
			<from-outcome>success</from-outcome>
			<to-view-id>/inbox.jsp</to-view-id>
		</navigation-case>
		<navigation-case>
			<from-outcome>failure</from-outcome>
			<to-view-id>/login.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
</faces-config>
Setup:
Eclipse Europe 3.3.0
Tomcat 6.0.13
MyFaces 1.2
JRE 1.6.0_02
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2008
Added on Sep 6 2007
3 comments
1,001 views