This is very much like extract method refactoring for Java.
Given a selection of HTML+Java mixture in JSP file and the name of the tag to be created (with tag library qualifier) present the "signature" preview dialog that will show up all the attributes new tag should have to get necessary values from out-of-selection context and the list of the variables (output values) new tag should define with suggestions (and ability to change) for their names.
Generating tag from the information collected seem to be straitforward (though complicated) process.