Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Dec 1999 14:35:48 -0800
From:      Sean Kelly <kelly@ad1440.net>
To:        Joe Yandle <joe@wlcg.com>
Cc:        java@freebsd.org
Subject:   Re: Servlet runners for FreeBSD ( + Apache)
Message-ID:  <38596944.D573D5D1@ad1440.net>
References:  <Pine.LNX.4.21.9912161653330.19510-100000@sith.wlcg.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> This is only half true.  While it does allow you to do <jsp:forward>, that
> doesn't help your servlets any.  For example, when writing servlet/jsp
> software I use the RequestDispatcher.forward() method to pass parameters
> from my servlets to my JSPs (separate logic, data, and
> presentation).  However, since the servlet-2.0 spec doesn't allow for
> this, my servlets can't do it.

That's right.  That's why I said I could do 1.0 JSP development, but
only 2.0 servlet development.  :-(

Here's a trick I'm not particularly proud of to get around the lack of
RequestDispatcher.forward() ... make sure you haven't eaten anything
before reading below:

public void doGet(...) {
     ...
     // create one or more beans and insert into user's session for
later
     // use by the JSP file.
     ...
     out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0
Frameset//EN\">");
     out.println("<html>");
     out.println("  <head>");
     out.println("    <title>Disgusting Trick</title>");
     out.println("  <frameset rows=\"*\">");
     out.println("    <frame src=\"/path/to/my.jsp\">);
     out.println("    <noframes>");
     out.println("      <body>");
     out.println("        <p>No 2.2 servlets means you have to have
frames.</p>");
     out.println("      </body>");
     out.println("    </noframes>");
     out.println("  </frameset>");
     out.println("</html>");
     ...
}

Basically, you force the client browser to do a separate GET/POST to
fetch the JSP page that the servlet could otherwise have forwarded to it
with the forward() method.

Worse, Netscape requires there to be at least two frames in a framed
HTML document, so you have to change the rows="*" to rows="*, 0" to get
the inner frame to go back to the web server and fetch the JSP file. 
Yuck.  (I hate to say this, but IE's adherence to the 4.0 HTML specs has
been a lot better than Netscape's.)

Client redirection could also do it, too.

Take care.
--Sean


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38596944.D573D5D1>