0

I have the following code in jsp page

<c:choose>
   <c:when test="${action == 'action1'}">
       Show me Part 1
   </c:when>
   <c:when test="${action == 'action2'}">
       Show me Part 2
   </c:when>
</c:choose>

I want to make a ajax call that will give the the value of "action" variable where this ajax call will connect with sevlet and that servlet will give me the value for action. so if servlet gives me the the value "action2" then "show me Part 2 should be visible"

I have done the following in JS and its calling this function on a button click action

function f1() {
    $.ajax({
        url: '/ProjectName/ServletName?action=ajtest',
        data: {test: "test"},
        success: function(response) {

        }
    });

}

I am getting the response normally without any problem but i want to set the value for action variable and see the result accordingly.

How to do this?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
LynAs
  • 6,407
  • 14
  • 48
  • 83
  • Sorry, JSP doesn't work that way. – Old Pro Jun 03 '13 at 01:48
  • what is the way around ? – LynAs Jun 03 '13 at 01:48
  • 2
    You must understand that EL/JSTL runs in view build time in the server side, so after any ajax action or update of the view (in this case, your JSP file) the EL/JSTL code won't be updated until you execute a forwarding or redirect to your page (since it triggers a new view build time phase). To handle ajax requests, refer to this Q/A: [How to use Servlets and Ajax?](http://stackoverflow.com/q/4112686/1065197) – Luiggi Mendoza Jun 03 '13 at 01:56

0 Answers0