----- Original Message -----
From: "Rakesh Bhalla" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Vincent Massol" <[EMAIL PROTECTED]>
Sent: Tuesday, September 18, 2001 1:51 PM
Subject: Significance of PageContext: forward ???
> Hello,
>
> --- Vincent Massol <[EMAIL PROTECTED]> wrote:
> >
> > It seems what you are really trying to do is functional testing
> > rather than unit testing. However, functional testing is also
> > possible with Cactus
> > although the main benefit is unit testing. Now, why would you want
> > to assert
> > the output of the JSP on the server side ?
> I am sorry for the trivial example given before. What I actually
> wanted to do is that store something on the session object and then
> try to assert it in the server.
>
> <% session.put( "name" , <some name> ); %>
ok! Then Cactus is the right tool .. :-)
>
> >
> > I think what you want to write is :
> >
> > public class MyJspTest extends JspTestCase
> > {
> > public void testXXX()
> > {
> > pageContext.forward("/some/path/myjsp.jsp");
> >
> > // (optional) assert values that the JSP would put in the
> > // session or pageContext or servlet context scope. In your
> > // example, there are none.
assertEquals("some value", session.getAttribute("some name"));
> > }
>
>
> Now what is the syntax of the pageContext.forward method here ?
> Is it the way we associate /some/path/myjsp.jsp with MyJspTest test
> case ?
>
I don't understand the question ? From the JSP spec :
"
JSP.9.2.1.8 Constructors
public PageContext ()
JSP.9.2.1.9 Methods
[...]
public abstract void forward (java.lang.String relativeUrlPath)
This method is used to re-direct, or "forward" the current ServletRequest
and
ServletResponse to another active component in the application.
If the relativeUrlPath begins with a "/" then the URL specified is
calculated
relative to the DOCROOT of the ServletContext for this JSP. If the path
does not begin with a "/" then the URL specified is calculated relative to
the
URL of the request that was mapped to the calling JSP.
It is only valid to call this method from a Thread executing within a _jsp-
Service(...)method of a JSP.
Once this method has been called successfully, it is illegal for the calling
Thread to attempt to modify the ServletResponse object. Any such
attempt to do so, shall result in undefined behavior. Typically, callers
immedi-ately
return from _jspService(...)after calling this method.
Parameters:
relativeUrlPath - specifies the relative URL path to the target resource as
described above
"
Note that you can also use pageContext.include() if you wish.
-Vincent