set a parameter to request object

86 views Asked by At

I'm using someone else's code, which has a method I can call to logout from a site. Inside this method I have the following condition:

   if (request.getParameter("logout") != null) {
       //the rest of the code     
   }

The problem is: how do I set the parameter of the "request" object so that the logout value can be something different than "null"? The condition expressed in the code always returns a "null" value, so the rest of the code is never executed. Is there a way to change the "logout" parameter so that I can still use this method, or is there another approach I should use?

1

There are 1 answers

0
nasioman On BEST ANSWER

If you want to add parameter to the request you need to append it to the URL.Depending on what API you use above Servlet API ,it might be different but the idea is the same:

RequestDispatcher dispatcher = request.getRequestDispatcher("/servlet/some.ThirdPartyServlet" + "?" + "param_name=" + "somevalue")