RequestDispatcher gives null??
Hello!I have a problem with a RequestDispatcher.
I have servlet (servlet1) is supposed to forward a request to a other servlet (servlet2) with a method below but when my other servlet2 is executed and I try to extract the parameters in the forwarded request added from a form, send to servlet1, the parameters is null.
I think this should be possible, but I can't get it right. If you take a look at the doc at: http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/javax/servlet/RequestDispatcher.html
Below my method in servlet1.
public void forward(String url) //url the path to servlet2
{
ServletContext servletContext = getServletContext();
RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher( url );
try
{
String[] myparam = (String[])request.getParameterValues("myparam");
if(counties == null)
{
System.out.println("NULL");
}
else
{
//This always works!! With other words I can read "myparam " in servlet1
System.out.println("NOT NULL");
for(int i = 0; i < myparam.length; i++)
{
System.out.println("->" + myparam[i]);
}
}
requestDispatcher.forward(request, response);
}
catch(ServletException se)
{
se.printStackTrace();
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}
Below the code in servlet2 where i try to read "myparam" that should be forwarded in the request.
String[] myparam = (String[])request.getParameterValues("myparam");
if(myparam == null)
{
//This always happens!!!
System.out.println("NULL");
}
else
{
System.out.println("NOT NULL ");
for(int i = 0; i < myparam.length; i++)
{
System.out.println(myparam[i]);
}
}
Please Help!!
Best regards
Fredrik
Ps
I use orion as server 1.5.2
