Solution 1 :

If you want to send the parameters through GET, then you should send them as query parameters, like: ?key1=value1&key2=value2.

For your use case, it should work if you replace the input type with the anchor element:

<a href="/your-path?test=value">link</a>

As a side note, just make sure that you understand the difference between GET and POST. Some notes here, or simply Google it. What you’ve tried, with the input submit element should be handled via POST, it’s really strange that it even worked in the first place.

Problem :

I current have some instances of input buttons and use request.getParameter to the request when the button is clicked. Like this:

<input type ="submit" name="test" value="test"/>

String t = request.getParameter("test");
    if (t != null) {
        System.out.print("k");
    }

I was wondering if there is a similar method for submitting data from a link , but I have not seen to come across any. In other words, I want to use a link instead for for the same result.

The application use servlets and the method=”get” to handle the submit.

Comments

Comment posted by Alexandru Somai

Could you give us please a bit more context on the app? Is it a Spring app? Or just some Servlets? Do you handle this request on POST or on GET?

Comment posted by egx

The application only use servlets and handles the request with method=”get”. I’ll edit the question to include these informations aswell.

Comment posted by Alexandru Somai

Well, it should work if you have the anchor as

Comment posted by egx

Thank you! This worked

Comment posted by Alexandru Somai

I’ll post an official answer for this 🙂

By