Java Reference
In-Depth Information
RequestDispatcher dispatcher=null;
if (fullThread.getSize()>0) {
dispatcher = servletContext.getRequestDispatcher("/JSP/
ShowThreadResults.jsp");
} else {
dispatcher = servletContext.getRequestDispatcher("/JSP/
messageNotFound.jsp");
}
dispatcher.forward(request, response);
We then dispatch to the JSP , which will display the results:
} catch (Throwable theException) {
try {
java.io.PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY BGCOLOR=#C0C0C0>");
out.println("<H2>Exception Occurred</H2>");
out.println(theException);
out.println("</BODY></HTML>");
} catch (Throwable exception) {
theException.printStackTrace();
}
}
}
Finally, we clean up and catch our exceptions.
The view for ShowThread
This is ShowThreadResults.jsp , which displays the results:
<HTML>
<jsp:useBean id="ShowThreadCommand" class="bbs.ShowThreadCommand"
scope="request"></jsp:useBean>
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<H1>All Messages</H1>
<P>
<h3>
Board: <%=ShowThreadCommand.getBoard(0)%></h3>
<TABLE border="1">
<TR>
<TD>Subject</TD>
<TD>Author</TD>
<TD>Post Text</TD>
Search WWH ::




Custom Search