Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

switch servlet

  Asked By: Daryl    Date: Feb 17    Category: Java    Views: 1329
  

I want to use request.getRequestDispatcher
("/servlet/Servlet1").forward(request, response) to switch to
another servlet. But this code don't work, because for switch to
another servlet , current servlet must terminate. I change that
code with this:
If(condition){
request.getRequestDispatcher
("/servlet/reportingsys.Servlet1").forward(request, response);
return;
}
and also I examine this code:
request.getRequestDispatcher
("/servlet/reportingsys.Servlet1").include(request, response);
but switch to servlet1 don't occure.(I use response.sendredirect
(req, res) also)
(I use applet and servlet communication and applet send a data to
servlet and after processing session, servlet return a data to
applet and switch to another page)
Can anybody help me?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Benny Torres     Answered On: Feb 17

you can use :
...
//initialize
String address = "";
if (condition){
address = "/servlet/servlet1";
}else{
address = "/servlet/servlet2";
}

request.getRequestDispatcher(address).forward(req,resp);
...

 
Didn't find what you were looking for? Find more on switch servlet Or get search suggestion and latest updates.




Tagged: