Koerr
Koerr

Reputation: 15723

How can I get URL parameters which have no value?

access using URL:

http://127.0.0.1/test.jsp?action=test&abc

or

http://127.0.0.1/test.jsp?abc

how can I get the String "abc" ?

thanks for help :)

Upvotes: 1

Views: 1114

Answers (3)

Ratna Dinakar
Ratna Dinakar

Reputation: 1573

request.getQueryString();

returns the whole query string after the URL.

Upvotes: 0

Enrique
Enrique

Reputation: 10117

<% java.util.Enumeration names = request.getParameterNames();
    while(names.hasMoreElements()){
        out.println(names.nextElement() + "<br>");
    }
    %>

Upvotes: 5

Stephen C
Stephen C

Reputation: 718738

I don't think there is a simple way to do this. Basically you need to iterate over the request's query parameter names and look for the parameter or parameters that don't have a value. I suspect that you will need to resort to embedding a Java scriptlet, or writing your own Tag (in Java).

A better idea is to stick to "name=value" syntax in your URL query.

Upvotes: 0

Related Questions