Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

J2ee:  need another pair of eyes.

Thread view: 
DaLoverhino - 22 Nov 2005 10:20 GMT
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.
HalcyonWild - 22 Nov 2005 19:48 GMT
> 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
[quoted text clipped - 5 lines]
>
> Anyways... here's the code (welcome.jsp, then gatherer.jsp):

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

> <jsp:directive.page />
>
[quoted text clipped - 16 lines]
>      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>
[quoted text clipped - 19 lines]
>   </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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.