*
The moose likes Servlets and the fly likes How to manually parse query args? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to manually parse query args?" Watch "How to manually parse query args?" New topic
Author

How to manually parse query args?

Jake Beard
Greenhorn

Joined: Oct 06, 2009
Posts: 6
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

Joined: Jan 10, 2002
Posts: 60741
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jake Beard
Greenhorn

Joined: Oct 06, 2009
Posts: 6
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: How to manually parse query args?
 
Similar Threads
doPut() and HTTP PUT
To authors of HFS
over writing a file on server
doPut and doHead example...
PUT method is not working in Tomcat