Q:

reload jsp custom tag with ajax and javascript

I have one jsp with some custom tag.  Because of the security concerns, I have changed the tag file as the following.  The field will be rendered as <label> when ever it contains readonly data and it will rendered as text field when it doesn't contain readonly data. 
Below is the code I use.  
<c:choose>
    <c:when test="${prot==true}">
         <label id="${jsvarname}">${status.value}</label>
    </c:when>
    <c:otherwise>
         <input type="text" name="${valueLocation}" id="${jsvarname}"/>
    </c:otherwise>
 </choose>

where prot is the value which specifies the field is readonly or not. 
And now my problem is, by any javascript event, it can be changed to either of the fields.  So I want to go for ajax to refresh the field.  I know how to populate the data through ajax request.  But I couldn't find any clue to reload the jsp custom tag with ajax request. 
I am using spring mvc. 
Any help with some code snippet will be appreciated. 
Thanks in advance.  

A:

Offhand, I would suggest you implement a controller method that returns a view (JSP) that only contains your custom tag. 
fragment.jsp:
<mytag prot="${protValue}" jsvarname="${jsvarnameValue}" valueLocation="${valueLocationVal}"/>

FragmentController:
@RequestMapping(value="/fragment-view", method = RequestMethod. GET)
public String getFragment(ModelMap model) {
    model.put("protValue", ...);
    model.put("jsvarnameValue", ...);
    model.put("valueLocationVal", ...);
    return "fragment";
}

You only have to invoke that method with AJAX and replace the old fragment with the html returned by the server.