Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to manually parse query args?

 
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
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
I was born with webbed fish toes. This tiny ad is my only friend:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic