An implementation question:

I can't see how to implement the relative paths (e.g. for the
<jsp:request forward>) in a JSDK-engine-independent way.  i.e. how to
implement JSP in a servlet strictly following the JSDK 2.1 API.

Scenario:
------------

/example -- this URL prefix defines a ServletContext, and maps to
/tmp/jsp
/example/foo/dest.jsp -- the destination JSP file
/example/foo/bar.jsp -- the forwarding JSP file as follows:

  <%@ page language='java' %>
  <jsp:request forward='dest.jsp'/>

--------------------

Presumably, the JSP implementation should somehow generate the following
code:

  application.getRequestDispatcher("/foo/dest.jsp").forward(request,
response);

But I can't see how to find out that /example is the URL root of the
current ServletContext.

A hack that might work for some some servlet implementations is the
following:
  String fullPath = request.getPathTranslated();          //
/tmp/jsp/foo/bar.jsp
  String rootPath = application.getRealPath("/");        //   /tmp/jsp
  String tail = fullPath.substring(rootPath.length());  //
/foo/bar.jsp

But that hack makes two shaky assumptions:
  1) Within a ServletContext, the mapping is a strict concatenation.
There's nothing in the JSDK 2.1 spec that implies this assumption.  And
several of the more clever URL rewriting engines, like Apache's
mod_rewrite, imply that I can't make this assumption.
  2) getPathTranslated() returns the translated path of the
requestURL().  This isn't true for all JSDK engines, especially for
extension matches.  (And really, getPathTranslated() should return null
in this case.  IMHO, the JSDK 2.1 spec is broken on this issue.  It
should follow the CGI spec.)

Does anyone have a clean solution?

Scott Ferguson
Caucho Technology

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to