This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to manually parse query args?

 
Jake Beard
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I was puzzled for a while as to why Tomcat does not seem to parse the query string in in the PUT data of the doPut method on my servlet. The effect of this is that it doesn't populate parameterMap in doPut. I found the answer on Stack Overflow:

http://stackoverflow.com/questions/855835/servlet-parameters-and-doput

My question now is, once I retrieve the PUT data into a string, how can I manually parse the query arguments into name-value pairs? It would be fairly easy to write this code myself, but this seems like such an easy, obvious thing to be able to do, I don't want to duplicate work that has likely already been done. This method is almost certainly to be found inside of Tomcat, but it may not be publicly exposed, and I can't seem to find it.

Please let me know what you think. Thanks,

Jake
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't use a Tomcat-proprietary method even if it were made public. Ties you to a a particular container, and that's a poor practice indeed.

I don't know of any available APIs that you can use, but perhaps there might be one somewhere in the Jakarta Commons project set. Personally, I'd just write a simple method to do it myself.
 
Jake Beard
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I wouldn't use a Tomcat-proprietary method even if it were made public. Ties you to a a particular container, and that's a poor practice indeed.

I don't know of any available APIs that you can use, but perhaps there might be one somewhere in the Jakarta Commons project set. Personally, I'd just write a simple method to do it myself.


I used the parse code here:

http://www.apl.jhu.edu/~hall/java/CGI-with-Java.html

Works quite well,

Jake
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic