java - how to use XML sent by html form? -


I have html form with textarea in which I paste some XML, for example:

  & lt; Network ip_addr = "10.0.0.0/8" save_ip = "true" & gt; & Lt; Subnet interf_used = "200" name = "lan1" /> & Lt; Subnet interf_used = "254" name = "lan2" /> & Lt; / Networks & gt;  

When the user submits the form, that data is sent to the Java server, so in the header I get something like this:

  get ? We =% 3Cnetwork + ip_addr% 3d% 2210.0.0.0% 2F8% 22 + save_ip% 3d% 22true% 22% 3E% 0 d% 0A% 3Csubnet + interf_used% 3% 22200% 22 + Name% 3% 22lan1% 22 +% 2F% 3E% 0D% 0A% 3Cubnet + interf_used% 3D% 22254% 22 + name% 3D% 22lan2% 22 +% 2F% 3E% 0D% 0A% 3C% 2Fnetwork% 3E HTTP / 1.1  

How can I use it in my Java applications? I need to calculate that data and resubmit the newly generated XML.

Displays how to use the URLDecoder / URLEncoder class to decode and encode the URL string. If you pass the 'GET' string to the URL decoder decode method, then it should work.


Answer your following question (comment)

First you need to remove this XML based response from the url string. Maybe & lt; It is enough to create a substrings starting with char.

The string should be fed into the XML parser to create a DOM document. The last simple task will be running through that document and will copy the values ​​in your internal network model.

Use a parser.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -