Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > J2ee: need another pair of eyes.

Reply
Thread Tools

J2ee: need another pair of eyes.

 
 
DaLoverhino
Guest
Posts: n/a
 
      11-22-2005
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.

 
Reply With Quote
 
 
 
 
HalcyonWild
Guest
Posts: n/a
 
      11-22-2005

DaLoverhino wrote:

> 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):
>


Anyway, what exactly is the error, you did not mention.

> <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.");
> }
>



Where are the JSP scriptlet tags. I assume you have them but did not
post here. If not, add them.

>
> </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>
>
>
>


Not really an endless loop if the value is being assigned properly. Any
diagnostic messages, any logs that are not being printed ? Post them
here.

Also, no need to keep the gatherer in Webinf folder. take it out.. keep
it in your webapps/myproject/ folder. Assuming that you are using
tomcat.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another easy pair of questions HMS Surprise Python 3 05-08-2007 09:38 PM
another pair of eyes... =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 0 07-12-2006 09:46 PM
Object expected; can't find it. Need another pair of eyes. Laiverd.COM Javascript 9 08-05-2004 06:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57