Get queryString using post method

If form method is kept as get, my problem at java servlet path is over, as i am able to get querystring. But due to some architecture problem, it is not feasible to make form method as get. So, how can I retrieve the same querystring using post method.
rajneetbhatiaAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
You can avoid hardcoding and save typing by doing

StringBuilder sb = new StringBuilder("?");
for(Enumeration e = req.getParameterNames();e.hasMoreElements();) {
      String param = e.nextElement().toString();
      sb.append(param)
            .append("=")
            .append(req.getParameter(param))
            .append("&");
}
String queryString = sb.toString().substring(0, sb.length() - 1);
0
 
objectsCommented:
you can access the passed parameters in the same way regardless of whether it is GET or POST
why do u need the query string exactly?
0
 
objectsCommented:
eg.

String value = request.getParameter("paramname");
0
 
objectsCommented:
If you need the query string then build it yourself

String queryString = "a="+request.getParameter("a")+"&b="+request.getParameter("b");  // add others as needed

0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.