hi buddy,
Try this example which i have made this may help you. As it displays the results on the same page.
<%@ page errorPage="error.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Generating Table </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY bgcolor=#FFCCFF>
<center>
<h1><font color="red">Colorful and Dynamic Table</font></h1>
<form method=post action="Table.jsp?name=Anthony">
<table>
<tr>
<td colspan="2"> <font size="2">
<%
int width=15;
int height=15;
%>
<font face="Arial, Helvetica, sans-serif"><b>Table width (Less than
16) =</b>
<input type=text name=width value=<%=width%> size=2>
, </font></font></td>
</tr>
<tr>
<td colspan="2"> <b><font face="Arial, Helvetica, sans-serif" size="2">Table
Height (Less than 16) = </font></b>
<input type=text name=height value=<%=height%> size=2>
, </td>
</tr>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><b>Select color
: -</b></font></td>
<td>
<select name="select">
<option value="#00FFFF" selected>Not specified</option>
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
<option value="Pink">Pink</option>
</select>
</td>
</tr>
<tr>
<td align=center colspan="2">
<input type=submit value="Click me Buddy !">
</td>
</tr>
</table>
</form>
<hr noshade>
<%
String w =request.getParameter("width");
String h= request.getParameter("height");
String col= request.getParameter("select");
if(w==null) w="15";
else w=request.getParameter("width");
if(h==null) h="15";
else h=request.getParameter("height");
if(col==null) col="#00FFFF";
else col=request.getParameter("select");
width = Integer.parseInt(w);
height = Integer.parseInt(h);
//if(width>15) width=15;
//if(width<0) width=0;
//if(height>15) height=15;
//if(height<0) height=0;
String[] colorArray={"00","11","22","33",
"44","55","66","77","88","99",
"AA","BB","CC","DD","EE","FF"};
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#CCCCCC" bgcolor=<%=col %>>
<tr>
<td align="center">
<table border=0 cellpadding =2 cellspacing=2>
<%
try {
%>
<%for (int y=0;y<=height;y++){%>
<tr>
<% for(int x=0;x<=width;x++) {
String bgColor="AA"+colorArray[y]+ colorArray[x];
%>
<td bgcolor=<%=bgColor%>> (<%=x%>,<%=y%> ) </td>
<%}%>
</tr>
<%}%>
<%
}
catch(Exception e)
{
out.print("<p align=justify><b>Please insert appropriate values. There is an Exception in your program which is :-"+e+"</b></p>");
}
%>
</table>
</td>
</tr>
</table>
<p>This is the following information which has been submitted to the server :-<br>
<b>This is width of the table :- <%=request.getParameter("width")%></b><br>
<b>This is heigth of the table :- <%=request.getParameter("height")%></b><br>
<b>This is bgcolor :- <%=request.getParameter("select")%></b><br>
</p>
<hr noshade>
</center>
</BODY>
</HTML>
The error page which i am printing is
<%@ page isErrorPage="true" import="java.io.*" %>
<HTML>
<HEAD>
<TITLE>This is my error </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY bgcolor="beige">
<h1 align=center>We have an error message here <%=request.getRemoteHost();%></h1>
<table border=1>
<tr>
<td>Exception</td>
<td><b><%=exception%></b></td>
</tr>
<tr>
<td>Message</td>
<td><b><%=exception.getMessage()%></b></td>
</tr>
<tr>
<td>Localized Messege</td>
<td><%=exception.getLocalizedMessage()%></td>
</tr>
<tr>
<td>Stack Trace</td>
<td><pre>
<%
StringWriter sw =new StringWriter();
PrintWriter pw=new PrintWriter(sw);
exception.printStackTrace(pw);
out.println(sw);
%></pre>
</td>
</tr>
</table>
<center><a href="javascript:history.back(0)">Please Enter your values again</a></center>
</BODY>
</HTML>
Use this two import the error page so that it also handles th exception. I hop ethi shelps you
abhinav