response.sendRedirect won't work JSP

N

nino9stars

Hello,

I am trying to make a "Please wait..." loading screen using JSP. I
sort of have it working (based on bits of information I found in the
groups), but not really. I created an IFrame to open in the JSP file
that displays the "Please wait..." animated gif. Now, in my code I
want to do some work and then redirect to the next page.

Problem is, when I keep the out.println(""); in the code, the "Please
wait..." sign works fine and the page is still loading, however it
won't redirect...

On the same token, if I remove the out.println(""); from the code,
then it does the work and redirects, but doesn't show the "Please
wait..." sign???

Any way to get both of these working together? Have it show the
"Please wait..." sign while it does the work, AND redirect to the next
step when it's done?

Here is my latest attempt:

<HTML>
<HEAD>
<TITLE>Loading Data...</TITLE>
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache">
<META http-equiv="Expires" content="-1">
<% //Make sure we DO NOT cache these pages
response.addHeader("Pragma", "no-cache");
response.addHeader("Expires", "-1");
%>
<LINK rel="stylesheet" href="styles.css" type="text/css">
</HEAD>

<BODY bgcolor="#FFFFFF" text="#404040" leftmargin="0" topmargin="0"
marginwidth="0" marginheight="0">

<iframe src="loadingScreen.html" width="500" height="500"></iframe>

</BODY>
</HTML>

<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="javax.servlet.*" %>

<%
session = request.getSession(true);
//session time-out clause
if ((session.isNew()) | (session.getAttribute("db") == null)) {
session.invalidate();
response.sendRedirect("TimeOut");
return;
}

String url = ""+session.getAttribute("db")+"";
String driver = ""+session.getAttribute("dr")+"";
String sqlu = ""+session.getAttribute("u")+"";
String sqlp = ""+session.getAttribute("p")+"";

String db_query = "";
ResultSet db_result;

Connection con;
Statement stmt;

try {
Class.forName(driver);
} catch (java.lang.ClassNotFoundException e) {
out.println("ClassNotFoundException " + e.getMessage());
} catch (Exception e) {
out.println("driver not "+e.getMessage()); }

try {
con = DriverManager.getConnection(url,""+sqlu+"",""+sqlp+"");
stmt = con.createStatement();

boolean redirectMe = false;

for (int x=0; x < 3; x++) {
db_query = "select fname, lname, track_id from USERS right join
TRACKS on track_id=user_id";
db_result = stmt.executeQuery(db_query);
while (db_result.next()) {
//out.println("");
}
redirectMe = true;
}

if (redirectMe) {
response.sendRedirect("sHome.jsp");
stmt.close();
con.close();
return;
}

stmt.close();
con.close();

} catch (SQLException ex) {
out.println("SQLException " + ex.getMessage());
}
%>

Thanks for any help... I greatly appreciate it...

Nino Skilj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top