5 Replies Latest reply on Aug 3, 2002 11:03 PM by aegcp

    <jsp:forward>, why do you hate me???

    aegcp

      hi all...

      I have a very simple jsp page that checks if a session exists. if it doesn't, it prompts a message to login, and if it does, it forwards the request to a servlet. The problem is that the servlet is never called!!!. i have even put a wrong servlet name to see if jetty complains but the only result I get is a blank page. here's my code.

      <%@page contentType="text/html"%>

      topics

      <jsp:include page="navigation.jsp" flush="true"/>


      <%
      String uname = null;
      uname = (String)session.getAttribute("userName");
      if (uname == null)
      {
      log("no session!");
      %>
      Please login first
      <%
      }
      else
      {
      log("performs forward");
      %>
      <jsp:forward page="/testapp/servlet/mobile.servlet.xxx"/>
      <%
      }
      %>





      I'm able to see my log message : "performs forward", but the forward is never accomplished... any ideas...???

      P.S: the blank page I get is:



      topics



      that's it... :-(

        • 1. Re: <jsp:forward>, why do you hate me???
          joelvogt

          It's never good when a jsp tag hates you. Can you call your servlet manually from your browser? ie
          localhost:8080/servlet.servletpath?

          If so, what have you got configured in your web.xml?

          And do you see servlet initialised ok on startup?

          • 2. Re: <jsp:forward>, why do you hate me???
            aegcp

            Hi and thanks for your response.

            Yes, I am able to call my servlet manually from my browser:

            http://localhost:8080/testapp/servlet/mobile.servlet.RetrieveTopics

            and a short snapshot of my web.xml is:

            <?xml version="1.0" encoding="ISO-8859-1"?>
            <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
            <web-app>

            <servlet-name>RetrieveTopics</servlet-name>
            <servlet-class>mobile.servlet.RetrieveTopics</servlet-class>

            <servlet-mapping>
            <servlet-name>RetrieveTopics</servlet-name>
            <url-pattern>/testapp/mobile.servlet.RetrieveTopics</url-pattern>
            </servlet-mapping>
            </web-app>

            so my forward is not working:
            <jsp:forward page="/testapp/servlet/mobile.servlet.RetrieveTopics"/>

            any ideas???

            • 3. Re: <jsp:forward>, why do you hate me???
              aegcp

              Hi guys.. me again..

              I have discovered something weird..

              my navigation.jsp that I use as an include is the following:


              <!--DWLayoutTable-->

              Create
              Topics | Create Subscription | log
              out






              If I do not use this include it works!!!... but what the heck is wrong with this include?? is this a bug???

              :-(

              • 4. Re: <jsp:forward>, why do you hate me???
                gregwilkins

                I think the problem is that you do an include with flush=true and some table stuff before the forward.

                By the time you get to the forward, the response has
                almost certainly been committed and it is too late to
                try to forward it.

                Normally a servlet or JSP that does a forward does not
                produce any output - else you are mixing your logic
                with your presentation.

                Try a JSP with just a forward in it and see if that works.

                • 5. Re: <jsp:forward>, why do you hate me???
                  aegcp

                  I took out the flush attribute and it worked...

                  thx