is it possible to clear struts2 file input tag?

I am using Struts2 for a web application development. i have this particular problem for which i couldnt find a solution even after i googled.

I have 3 tags with a hyperlink or button against each, which has to be used to clear the filepath if anything was previously selected. The solution which was found online was to reset the form.. but then all the s:file tags will be cleared since all tags need to be in the same form.

Is there any way to clear a single file input on some click??


One solution similar to what we've used is to remove the input element and create a new input element in its place, with the same name.

EDIT: Here's an example I threw together.

<script type="text/javascript">
    function clearFoo() {
        var inp = document.getElementById("foo");
        var parent = inp.parentNode;

        // Create the new input element.
        // Copy over any attributes you need.
        var newInp = document.createElement("input");
        newInp.type = "file"; =;

        // Replace the old node with the new node.
        parent.insertBefore(newInp, inp);

        // The new node is the new "foo". = "foo";

<s:file id="foo" name="foo"/>

<button onclick="clearFoo();">Click</button>

Need Your Help

Authentication for a web page via browser

javascript jquery html

I am working on a Laravel project right now. I have a route All I want is that when a hits this page, he should be asked for some credentials. If he inputs incorrect

How to change bower-installer path for one component

javascript node.js bower bower-install

I am using bower-installer to copy files I need from bower_components folder into bower_dist folder. Here is relevant part of bower.json file: