Keep in mind, it is ultimately the HTTP protocol that determines how parameters get past. As such, the same syntax is used for Servlets that is used for regular HTML pages.
So the syntax you listed is correct. When using a href link, the request method will be a GET and thus Servlet�s doGet() method is called (if the parameters are past as part of a from, and the form�s method is post, the doPost() method is called).
When using the link <a href="/actionController?id=1&sid=2">Menu Option</a> is your Servlet not working? If so, what is the problem or error message you are getting. In addition, can you post the code from your Servlet in which you are accessing the Parameters.
If this is a case where you did not create the Servlet, one thing to be aware of, it is not an uncommon practice (for security purposes) for a Servlet to allow parameters only to be received via a POST. Sometimes the Servlet may even be coded such that if any parameters are received via a GET, it does not simply ignore them and function as if none were received; it may display an error.
Joined: Nov 14, 2008
Hi, This post is old but have some valuable information. If somebody visits it please let me know if we donot want to use href GET method property ,is there some way we can use POST method in href. Reason for my question is I want to use href links only for a application where form cannot be used due to some resons.but as in href parameters being passed are displayed in URL as soon as they are clicked it is ,i donot want it to be displayed in URL.
If the above case doesn't works in any condition then do we have any alternative to this situation where POST method should be used without using form tag......
Joined: Sep 25, 2006
You can try and emulate the HTML Form structure and submission through HTTPClient. This is to get you started.