Title: simulating jsp:forward in a java function - is the following "right"?

(sorry about the trimmed message, pressed ^S in error)

Hello,

We are trying to write a function which will:

1. be callable from within a JSP page.
2. able to do server-side forwarding to a RELATIVE URL,
   a-la <jsp:forward ...>

Our current environment is New-Atlanta's ServletExec 3.0
beta and Sun JDK 1.2.2 running on Windows 2000.  This
version of ServletExec supports Servlet 2.2 and JSP 1.1.

Use of standard RequestDispatcher.forward requires a full
URL, which jsp:forward manages to avoid.

So what we did was to copy the code generated by ServletExec
for a JSP page and put it in a function, like this:

  public static void forward(Servlet servlet, ServletContext application,
    HttpServletRequest request, HttpServletResponse response)
  {
    JspFactory jspfactory = JspFactory.getDefaultFactory();

    PageContext pageContext = jspfactory.getPageContext(servlet, request, response,
      "null", true, 8, true );

    try {
        pageContext.forward("Login.jsp");
    }
    catch (Exception e)
    {
      throw new RuntimeException();
    }
    finally
    {
      jspfactory.releasePageContext( pageContext );
    }
  }

It seems to work, but I wander if this is the "right" way to do it.
Reading the JavaDoc for the classes used here it looks like they
are all standard.

Any comments would be greatly appreciated, even just "it's alright".

Thanks,

--Amos Shapira

Reply via email to