D
DaLoverhino
Hello. I am trying to learn J2EE. I've been poking around with the
following which seems like an infinite loop. I know I must be doing
something simply stupid, but I can't figure it out. Anyways, my
welcome-file, welcome.jsp forwards to gatherer.jsp which then forwards
back to welcome.jsp. Sounds like an infinite loop, but welcome.jsp
checks to see if a string is null, and this string is suppose to be set
in gatherer.jsp.
Anyways... here's the code (welcome.jsp, then gatherer.jsp):
<jsp:directive.page />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Passing stuff around.</title>
</head>
<body>
String user = (String) session.getAttribute("user");
if( user == null) {
<jsp:forward page="WEB-INF/gatherer.jsp">
<jsparam name="doWhat" value="getName" />
</jsp:forward>
}
else {
out.println( "Hello there, " + user + ". Nice to meet you.");
}
</body>
</html>
Now gatherer.jsp which is in WEB-INF subdirectory:
<jsp:directive.page
errorPage="/WEB-INF/errorPage.jsp" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String actionCode = request.getParameter( "doWhat");
session.setAttribute( "user", new String("Fred Flintstone"));
out.println( "The action requested was : " + actionCode + ". Heck
yeah.");
%>
<p>Go back to <a href="welcome.jsp">welcome page</a></p>
</body>
</html>
Thanks.
following which seems like an infinite loop. I know I must be doing
something simply stupid, but I can't figure it out. Anyways, my
welcome-file, welcome.jsp forwards to gatherer.jsp which then forwards
back to welcome.jsp. Sounds like an infinite loop, but welcome.jsp
checks to see if a string is null, and this string is suppose to be set
in gatherer.jsp.
Anyways... here's the code (welcome.jsp, then gatherer.jsp):
<jsp:directive.page />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Passing stuff around.</title>
</head>
<body>
String user = (String) session.getAttribute("user");
if( user == null) {
<jsp:forward page="WEB-INF/gatherer.jsp">
<jsparam name="doWhat" value="getName" />
</jsp:forward>
}
else {
out.println( "Hello there, " + user + ". Nice to meet you.");
}
</body>
</html>
Now gatherer.jsp which is in WEB-INF subdirectory:
<jsp:directive.page
errorPage="/WEB-INF/errorPage.jsp" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<%
String actionCode = request.getParameter( "doWhat");
session.setAttribute( "user", new String("Fred Flintstone"));
out.println( "The action requested was : " + actionCode + ". Heck
yeah.");
%>
<p>Go back to <a href="welcome.jsp">welcome page</a></p>
</body>
</html>
Thanks.