To me it looks like the problem with your code is, that you try to forward
after already having committed a response to the out-object (via your
mailForm, which instantiates a PrintStream), which is not possible.
Hope this helps
Michael
-----Ursprungliche Nachricht-----
Von: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]Im Auftrag von Patrick Pierra
Gesendet: Freitag, 11. Mai 2001 14:07
An: [EMAIL PROTECTED]
Betreff: Re: response already commited
String mailForm (HttpServletRequest req) throws JspException{
StringBuffer message = new StringBuffer();
Enumeration fields = fieldList.elements();
while (fields.hasMoreElements()) {
formField field = (formField)fields.nextElement();
message.append(field.name)
.append(" : ")
.append(req.getParameter(field.name))
.append("\n");
}
System.out.println(message.toString());
// Nouveau JavaMail here.
try {
SmtpClient client = new SmtpClient(mailhost);
client.from(senderAddress);
client.to(formRecipient);
PrintStream msg = client.startMessage();
msg.println();
msg.println();
msg.println("Sujet : Feedback Web");
msg.println();
msg.println(message.toString());
msg.println("--");
msg.println("Message from [EMAIL PROTECTED]");
client.closeServer();
} catch (IOException e) {
e.printStackTrace();
}
return (message.toString());
}
%>
<%
if (isValidForm(request)) {
User tUser = new User(); // here is the problem
/*tUser.setMUserName(request.getParameter("UserName"));
tUser.setMPassword(request.getParameter("Password"));
session.setAttribute("user", tUser);*/
mailForm(request);
// need to create a 'thanks for your comments' page
//response.sendRedirect("footer_help/thanks.jsp");
%>
<jsp:forward page="thanks.jsp"/>
<% }
%>
> Hello,
>
> I' try to create an Object in a JSP :
>
> <%
> User tUser = new User();
> ......
> %>
>
> When i run this JSP on Tomcat i receive this error message :
>
> Error: 500
> Location: /odata1/Registration.jsp
> Internal Servlet Error:
> java.lang.IllegalStateException: Response has already been committed
> java.lang.Throwable(java.lang.String)
> java.lang.Exception(java.lang.String)
> java.lang.RuntimeException(java.lang.String)
> java.lang.IllegalStateException(java.lang.String)
> void
> org.apache.tomcat.core.HttpServletResponseFacade.sendError(int,
> java.lang.String)
> void
>
org.apache.jasper.runtime.JspServlet.unknownException(javax.servlet.http.Htt
pServletResponse,
>
> java.lang.Throwable)
> void
>
org.apache.jasper.runtime.JspServlet.service(javax.servlet.http.HttpServletR
equest,
>
> javax.servlet.http.HttpServletResponse)
> void
> javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest,
> javax.servlet.ServletResponse)
> void
>
org.apache.tomcat.core.ServletWrapper.handleRequest(org.apache.tomcat.core.R
equest,
>
> org.apache.tomcat.core.Response)
> void
>
org.apache.tomcat.core.ContextManager.service(org.apache.tomcat.core.Request
,
>
> org.apache.tomcat.core.Response)
> void
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(org.a
pache.tomcat.service.TcpConnection,
>
> java.lang.Object [])
> void org.apache.tomcat.service.TcpConnectionThread.run()
> void java.lang.Thread.run()
>
>
> any explication ?
>
> Patrick PIERRA
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets