How do I add a hidden input tag using the Jericho HTML Parser?

91 Views Asked by At

For each form in an HTML page I want to add an additional hidden input tag as it passes through a JEE Filter. For a given HTML page for example:

 <html>
    <form name="input" action="submit.jsp" method="post">
         <input type="hidden" name="id" value="1"/>
         <input type="submit" value="Submit"/>
     </form>
 </html>

the end result should be similar to this:

 <html>
    <form name="input" action="submit.jsp" method="post">
         <input type="hidden" name="id" value="1"/>
         <input type="submit" value="Submit"/>
         <input type="hidden" name="dynamickey" value="DYNAMIC_VALUE_HERE"/>
     </form>
 </html>

As the HTML may be malformed, I am figuring that Jericho would be the HTML parser of choice. After a couple of passes through the web pages, I have found ways to change the values of already existing tags, but how to add an additional tag escapes me.

Thanks in advance for help.

0

There are 0 best solutions below