Hi Miroslav, I appreciate your attempt to answer.But to be frank I am not sure what you mean.Could you modify my code snippet & let me know how you do it programmatically?
Thanks in advance Best Regards, Prithvi http://www.prithvibhat.com --- Miroslav ulc <[EMAIL PROTECTED]> wrote: > Hi Prithvi, > > I'm still in the "before newbie" stage but I guess > it won't work the way > you expect. I think it works this way: > > You say: "Hey, give me http://localhost/" > And you get: "Hey, you should send request for > http://localhost/default.html (or > http://localhost/tp/default.html) to > the server" > > And then in the next request you can get the content > of the page you are > redirected to. So what you get is the information > that you should send > request for another page, not the new page itself. > You'll get the new > page on the next request (if you make the next > request). > > I hope this helps. > > -- > Miroslav > > Prithvi Bhat wrote: > > Hi All, > > I am going mad with testing servlet > redirections > > using cactus.There are tons of articles on cactus > on > > the internet.None of them did help.I bought > Vincent > > Massol's book "Junit in Action" that too did not > help. > > Any one's help in this regard would be deeply > > appreciated. > > > > My sample servlet to be tested is as below > > ============================================== > > > > import java.io.IOException; > > import javax.servlet.http.HttpServlet; > > import javax.servlet.http.HttpServletResponse; > > import javax.servlet.http.HttpServletRequest; > > > > > > public class SampleServlet extends HttpServlet > > { > > > > public void RedirectPage(HttpServletRequest > > request,HttpServletResponse response) > > throws IOException > > { > > String strRedirectorFlag = > > request.getParameter("strRedirectorFlag"); > > > > > System.out.println("strRedirectorFlag"+strRedirectorFlag); > > > > if (strRedirectorFlag.equals("1") ) > > { > > > > > > > response.sendRedirect("http://localhost/default.html"); > > } > > else > > { > > > > > > > response.sendRedirect("http://localhost/tp/default.html"); > > } > > > > } > > }//class SampleServlet > > > =================================================== > > My test servlet is as below > > > =================================================== > > import java.io.IOException; > > import junit.framework.Test; > > import junit.framework.TestSuite; > > > > import org.apache.cactus.ServletTestCase; > > import org.apache.cactus.WebRequest; > > import org.apache.cactus.WebResponse; > > > > public class TestSampleServlet extends > > ServletTestCase > > { > > > > public void beginRedirection(WebRequest > > webRequest) > > { > > > webRequest.addParameter("strRedirectorFlag","1"); > > } > > > > public void testRedirection() > > throws IOException > > { > > SampleServlet servlet = new > > SampleServlet(); > > > > servlet.RedirectPage(request,response); > > } > > > > public void endRedirection(WebResponse > > webResponse) > > { > > > > > System.out.println("Response"+webResponse.getText()); > > > > > assertTrue("udupi",webResponse.getText().indexOf("<TITLE>prithvibhat.com > > - Comprehensive information on Udupi</TITLE>") > > > > 0); > > } > > > > } > > > > > =================================================== > > > > If you see the code carefully in my Test case I > want > > to check whether the redirection in my servlet > was to > > > > http://localhost/default.html or > > http://localhost/tp/default.html > > > > So I use the response.getText() method to compare > it > > with the page contents.Unfortunately getText() > method > > always returns me NULL! > > > > Please help... > > > > Best Regards, > > Prithvi > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]