HttpSession aSession = request.getSession(true);
String destination = "/login.jsp?returnPage=/practice/reviewcontent.jsp";
try{
if(aSession.getValue("userId") == null) {
%>
<jsp:forward page="<%= destination %>" />
<%
}
%>
thank you
error msg ...
==================
Error: 500
Location: /practice/reviewcontent.jsp
Internal Servlet Error:
java.io.IOException: Error: Attempt to clear a buffer thats already been
flushed
at org.apache.jasper.runtime.JspWriterImpl.clear(JspWriterImpl.java:180)
at practice.reviewcontent_6._jspService(reviewcontent_6.java:93)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
at org.apache.tomcat.core.Handler.service(Handler.java:235)
at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(Ajp13Interceptor.java:341)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
at java.lang.Thread.run(Thread.java:536)
entire code..
========================
<jsp:include page="/shared/withoutN_header.html" flush="true"/>
<%@ page import="java.util.*, practice.*, javax.servlet.*,
javax.servlet.http.*, java.io.*"%>
<%
String title=null;
String contentId = request.getParameter("contentId");
String content = request.getParameter("content");
String contentTitle = request.getParameter("contentTitle");
HttpSession aSession = request.getSession(true);
String destination =
"/login.jsp?returnPage=/practice/reviewcontent.jsp";
if(aSession.getValue("userId") == null) {
%>
<jsp:forward page="<%= destination %>" />
<%
}
title = "Review " + "<br>" + contentTitle + "<br>" + content;
String errorMsg=null;
if(request.getParameter("errorMsg") != null){
errorMsg = request.getParameter("errorMsg");
}
else
errorMsg = "";
%>
<h3>Review</h3>
<h4><%= contentTitle%></h4>
<%= content%>
<form method=post action=/servlet/practice.ReviewContent?contentId=<%=
contentId %> >
<table>
<tr>
<td align=center><font color=red>
<%= errorMsg %>
</font>
</td>
</tr>
<tr>
<td>Items marked with a * are required
</td>
</tr>
<tr><td>Rate: * </td><td><select name=rating >
<option value=> -
<option value=5>5 stars
<option value=4>4 stars
<option value=3>3 stars
<option value=2>2 stars
<option value=1>1 star
</select>
</td></tr>
<tr><td>Comments: </td><td><textarea rows=5 cols=30 name=description>
</textarea></td></tr>
<hr>
</td></tr>
<tr><td colspan=2 align=center><input TYPE=submit value="Add"></td></tr>
</table>
</form>
<jsp:include page="/shared/withoutN_footer.html" flush="true"/>
You can't do a forward when you have started writing to a page, which
you seems to do with your include. You must do the forward before
writing any output to the page.
/Daniel