J2ee: need another pair of eyes.

Discussion in 'Java' started by DaLoverhino, Nov 22, 2005.

  1. DaLoverhino

    DaLoverhino Guest

    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">
    <jsp:param 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.
     
    DaLoverhino, Nov 22, 2005
    #1
    1. Advertising

  2. DaLoverhino

    HalcyonWild Guest

    Re: J2ee: need another pair of eyes.

    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">
    > <jsp:param 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.
     
    HalcyonWild, Nov 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel
    Replies:
    0
    Views:
    343
    darrel
    Jun 21, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: need second pair of eyes: databinder.eval problem

    Phil Winstanley [Microsoft MVP ASP.NET], Jun 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    432
    darrel
    Jun 21, 2004
  3. =?Utf-8?B?cm9kY2hhcg==?=

    another pair of eyes...

    =?Utf-8?B?cm9kY2hhcg==?=, Jul 12, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    332
    =?Utf-8?B?cm9kY2hhcg==?=
    Jul 12, 2006
  4. Laiverd.COM
    Replies:
    9
    Views:
    102
    Richard Cornford
    Aug 5, 2004
  5. Luminousc
    Replies:
    4
    Views:
    1,095
    Erwin Moller
    Mar 25, 2005
Loading...

Share This Page