?
Solved

Get queryString using post method

Posted on 2007-10-16
5
Medium Priority
?
2,442 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:rajneetbhatia
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20084917
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
 
LVL 92

Expert Comment

by:objects
ID: 20084962
eg.

String value = request.getParameter("paramname");
0
 
LVL 92

Expert Comment

by:objects
ID: 20084987
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 20087817
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 20091264
:-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question